Detecting Full Initialization Points of Objects to Support Code Refactorings

A common need of refactorings that involve object allocations is to determine precisely the program points at which objects allocated at a given allocation site become fully initialized. In this paper we formalize the notion of full initialization points (FIPs) of allocation sites, and present a static analysis to determine precisely these program points. While this analysis can benefit several allocation-site refactorings, to demonstrate its usefulness we select two specific refactorings in this paper - object sharing refactoring and immutability refactoring. By introducing code to cache and share objects at the FIPs suggested by our analysis, object-sharing refactoring was able to obtain a mean memory savings of 11.4% on a set of real Java benchmarks. Immutability refactoring guided by our analysis achieved a mean runtime speedup of 1.6X compared to performing the same refactoring using a baseline approach.

[1]  Paddy Nixon,et al.  Automated software evolution towards design patterns , 2001, IWPSE '01.

[2]  Mel Ó Cinnéide Automated refactoring to introduce design patterns , 2000, Proceedings of the 2000 International Conference on Software Engineering. ICSE 2000 the New Millennium.

[3]  Stephen N. Freund,et al.  A Type System For Object Initialization In the Java Bytecode Language , 1997, Electron. Notes Theor. Comput. Sci..

[4]  Songtao Xia,et al.  Establishing object invariants with delayed types , 2007, OOPSLA.

[5]  A. Murdoch Cloning , 2007 .

[6]  Barbara G. Ryder,et al.  Parameterized object sensitivity for points-to analysis for Java , 2005, TSEM.

[7]  Xin Qi,et al.  Masked types for sound object initialization , 2009, POPL '09.

[8]  Raghavan Komondoor,et al.  A dynamic analysis to support object-sharing code refactorings , 2014, ASE.

[9]  Erik Poll,et al.  Type-based Object Immutability with Flexible Initialization - extended version , 2009 .

[10]  K. Rustan M. Leino,et al.  Declaring and checking non-null types in an object-oriented language , 2003, OOPSLA 2003.

[11]  Frances E. Allen,et al.  Control-flow analysis , 2022 .

[12]  Marc Snir,et al.  Transformation for class immutability , 2011, 2011 33rd International Conference on Software Engineering (ICSE).

[13]  Marc Snir,et al.  Refactoring for Immutability , 2010 .

[14]  Monica S. Lam,et al.  Automatic inference of stationary fields: a generalization of java's final fields , 2008, POPL '08.

[15]  Ravichandhran Madhavan,et al.  Null dereference verification via over-approximated weakest pre-conditions analysis , 2011, OOPSLA '11.