Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introducing PackagePrivateProcessorPass
Summary: ``` /* * Before Android 4.1, Dalvik did not honor package-private accessibility * restrictions when constructing vtables, see * https://developer.android.com/guide/practices/verifying-apps-art#Object_Model_Changes * * The original design of Redex somewhat reflected this attitude, not giving * proper considerations for package-private access rules. In particular, the * MethodOverrideGraph, the VirtualScope facitities, the RenameClasses* * transformation, but also many other aspects in Redex basically assume that * all members are public. For all internal classes, those assumptions are * largely "made true" by the aptly named MakePublicPass. However, there are a * few semantic problems, such as the following: * - By making everything public, the MakePublicPass may truely establish * overriding relationships between methods that, due to original limited * package private access, shouldn't actually be in an overriding * relationship. * - By changing the package name of classes to just X, the RenameClasses* * passes may break package-private access. * * This pass aims at working out those issues by performing certain * transformations upfront: * - For apparent overrides that are not actually overrides because of * package-private access and different package names, we treat those as new * virtual scope roots, and rename all involved methods uniquely. * - Where actual accesses to package private members occur, we make * the members public, effectively making all accesses public accesses, so * that existing Redex' optimizations are free to move around code and rename * packages, and don't have to worry about package-private access rules. * * There are few limitations to this approach: * - New virtual scopes might implement interfaces, in which case renaming the * methods might break the interface. We currently just give up, stopping * Redex. (TODO: We could still handle this in some cases, renaming also * interface methods, and possibly introducing some bridge methods.) * - Some public methods might override multiple (formerly package private) * virtual roots. We don't currently support this. * - Some methods might be marked as do-not-rename. * * We don't currently hit any of those limitations. * * With these transformations, the MakePublicPass should no longer needed for * fixing up package private accesses (but it might still be needed to fix up * other effects of Redex transformation on visibility) */ ``` Reviewed By: wsanville Differential Revision: D55435220 fbshipit-source-id: ef95f09ece87c61fa0ca77a0551002e81e6e8cfc
- Loading branch information