Journal "Software Engineering"
a journal on theoretical and applied science and technology
ISSN 2220-3397
Issue N8 2016 year
Application extraction, i.e. elimination of unused methods, fields and classes during Java program romization is considered. Eager class initialization is one of the romization optimizations. Class initialization in Java involves executing class initializers which can contain arbitrary Java code. Objects created during class initialization might affect the reachability of methods, fields and classes in non-trivial ways. Existing analysis algorithms dont take these objects into account. We propose a reachability analysis algorithm which selectively initializes classes and takes objects created by class initializers into consideration. This algorithm is based on Rapid Type Analysis (RTA) algorithm which keeps track of classes which can be instantiated by reachable methods. The set of instantiable classes is used to determine which methods can be invoked by virtual and interface calls. The algorithm we propose also keeps track of classes which can be initialized by reachable methods. The algorithm initializes a subset of these classes using a simple heuristic to choose which classes are safe to initialize. All the objects which remain reachable after class initialization are considered to be reachable for the application. These objects could be used for virtual and interface calls. Therefore classes of reachable objects are included into the set of instantiable classes. We also propose a field reachability analysis algorithm which takes live objects into account. Field removal might affect object reachability and might cause some objects to be collected by GC. In some cases that can be observable by the application even if it never accesses the object explicitly. For example, if the object is finalizable or a special reference is held for this object. The proposed algorithm takes these dependencies into account. Finally we propose a class reachability analysis algorithm which takes aforementioned analyses into account.