Journal "Software Engineering"
a journal on theoretical and applied science and technology
ISSN 2220-3397

Issue N8 2016 year

DOI: 10.17587/prin.7.339-350
Application Extraction and Selective Class Initialization for Java
A. V. Pilipenko, e-mail: artur.pilipenko@gmail.com, Saint Petersburg State University, 199034, Saint Petersburg, Russian Federation, O. A. Pliss, oleg.pliss@gmail.com, Oracle Corporation, CA 94065, Santa Clara, USA
Corresponding author: Pilipenko Artur V., Postgraduate Student, Saint Petersburg State University, artur.pilipenko@gmail.com, Saint Petersburg, Russian Federation, e-mail: artur.pilipenko@gmail.com
Received on May 10, 2016
Accepted on May 30, 2016

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.

Keywords: Java, virtual machine, romization, class initialization, application extraction, reachability analysis, GC
pp. 339–350
For citation:
Pilipenko A. V., Pliss O. A. Application Extraction and Selective Class Initialization for Java, Programmnaya Ingeneria, 2016, vol. 7, no. 8, pp. 339—350