Abstract
Java programmers can document that the relationship between two objects is unchanging by declaring the field that encodes that relationship to be final. This information can be used in program understanding and detection of errors in new code additions. Unfortunately, few fields in programs are actually declared final. Programs often contain fields that could be final, but are not declared so. Moreover, the definition of final has restrictions on initializationthat limit its applicability.
We introduce stationary fields as a generalization of final. A field in a program is stationary if, for every object that contains it, all writes to the field occur before all the reads. Unlike the definition of final fields, there can be multiple writes during initialization, and initialization can span multiple methods.
We have developed an efficient algorithm for inferring which fields are stationary in a program, based on the observation that many fields acquire their value very close to object creation. We presume that an object's initialization phase has concluded when its reference is saved in some heap object. We perform precise analysis only regarding recently created objects. Applying our algorithm to real-world Java programs demonstrates that stationary fields are more common than final fields: 44-59% vs. 11-17% respectively in our benchmarks.
These surprising results have several significant implications. First, substantial portions of Java programs appear to be written in a functional style. Second, initialization of these fields occurs very close to object creation, when very good alias information is available. These results open the door for more accurate and efficient pointer alias analysis.
- Jong-Deok Choi, Manish Gupta, Mauricio Serrano, Vugranam C. Sreedhar, and Sam Midkiff. Escape analysis for java. In OOPSLA '99: Proceedings of the 14th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, pages 1--19, New York, NY, USA, 1999. ACM Press. Google Scholar
Digital Library
- Jeffrey Dean, David Grove, and Craig Chambers. Optimization of objectoriented programs using static class hierarchy analysis. In ECOOP'95: Proceedings of the 9th European Conference on Object-Oriented Programming, pages 77--101, London, UK, 1995. Springer-Verlag. Google Scholar
Digital Library
- Dawson Engler, David Yu Chen, Seth Hallem, Andy Chou, and Bejamin Chelf. Bugs as deviant behavior: A general approach to inferring errors in systems code. In Proceedings of Eighteenth ACM Symposium on Operating System Principles, pages 57--72, October 2001. Google Scholar
Digital Library
- Jeffrey S. Foster, Manuel Fäahndrich, and Alexander Aiken. A theory of type qualifiers. In PLDI '99: Proceedings of the ACM SIGPLAN 1999 Conference on Programming Language Design and Implementation, pages 192--203, New York, NY, USA, 1999. ACM Press. Google Scholar
Digital Library
- James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification, Third Edition. The Java Series. Addison-Wesley, Boston, Mass., 2005. Google Scholar
Digital Library
- Samuel P. Harbison and Guy Steele. C, A Reference Manual. Prentice-Hall, Inc., New York, NY, 1987. Google Scholar
Digital Library
- David L. Heine and Monica S. Lam. A practical flow-sensitive and context-sensitive C and C++ memory leak detector. In PLDI '03: Proceedings of the ACM SIGPLAN 2003 Conference on Programming Language Design and Implementation, pages 168--181, New York, NY, USA, 2003. ACM Press. Google Scholar
Digital Library
- David L. Heine and Monica S. Lam. Static detection of leaks in polymorphic containers. In ICSE '06: Proceedings of the 28th International Conference on Software Engineering, pages 252--261, New York, NY, USA, 2006. ACM Press. Google Scholar
Digital Library
- Gunter Kniesel and Dirk Theisen. JAC - acess right based encapsulation for Java. Software - Practice and Experience, 31(6):555--576, 2001. Ted Kremenek, Paul Twohey, Godmar Back, Andrew Ng, and Dawson Engler. From uncertainty to belief: inferring the specification within. In USENIX'06: Proceedings of the 7th conference on USENIX Symposium on Operating Systems Design and Implementation, pages 12--12, Berkeley, CA, USA, 2006. USENIX Association. Google Scholar
Digital Library
- Viktor Kuncak, Patrick Lam, and Martin Rinard. Role analysis. In POPL'02: Proceedings of the 29th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 17--32, New York, NY, USA, 2002. ACM Press. Google Scholar
Digital Library
- Benjamin Livshits and Thomas Zimmermann. DynaMine: finding common error patterns by mining software revision histories. In ESEC/FSE--13: Proceedings of the 10th European software engineering conference held jointly with 13th ACM SIGSOFT international symposium on Foundations of software engineering, pages 296--305, New York, NY, USA, 2005. ACM Press. Google Scholar
Digital Library
- Peter Muller and Arnt Poetzch-Heffter. A type system for controlling representation exposure in Java. In 2nd ECOOP Workshop on Formal Techniques for Java Programs, 2001. Igor Pechtchanski and Vivek Sarkar. Immutability specification and its applications. In JGI '02: Proceedings of the 2002 joint ACM-ISCOPE conference on Java Grande, pages 202--211, New York, NY, USA, 2002. ACM Press. Google Scholar
Digital Library
- Sara Porat, Marina Biberstein, Larry Koved, and Bilha Mendelson. Automatic detection of immutable fields in Java. In CASCON '00: Proceedings of the 2000 Conference of the Centre for Advanced Studies on Collaborative research, page 10. IBM Press, 2000. Google Scholar
Digital Library
- A. Salcianu and M. Rinard. Purity and side effect analysis for Java programs. Lecture Notes in Computer Science, 3385:199--215, 2005. Google Scholar
Digital Library
- Mats Skoglund and Tobias Wrigstad. A mode system for readonly references. In Akos Frohner, editor, Formal Techniques for Java Programs, number 2323 in Object-Oriented Technology, ECOOP 2001 Workshop Reader, pages 30--, Berlin, Heidelberg, New York, 2001. Springer-Verlag. ISBN 3-540-43675-8. Google Scholar
Digital Library
- Dave Thomas, Chad Fowler, and Andy Hunt. Programming Ruby: The Pragmatic Programmer's Guide, Second Edition. Addison-Wesley, 2005. Google Scholar
Digital Library
- Matthew S. Tschantz and Michael D. Ernst. Javari: Adding reference immutability to Java. In Object--Oriented Programming Systems, Languages, and Applications (OOPSLA 2005), pages 211--230, San Diego, CA, USA, October 18--20 2005. Google Scholar
Digital Library
- John Whaley. Joeq: A virtual machine and compiler infrastructure. In Proceedings of the SIGPLAN Workshop on Interpreters, Virtual Machines, and Emulators, pages 58--66, June 2003. Google Scholar
Digital Library
- John Whaley and Martin Rinard. Compositional pointer and escape analysis for java programs. In OOPSLA '99: Proceedings of the 14th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, pages 187--206, New York, NY, USA, 1999. ACM Press. Google Scholar
Digital Library
- Chadd C. Williams and Jeffrey K. Hollingsworth. Recovering system specific rules from software repositories. In MSR '05: Proceedings of the 2005 international workshop on Mining software repositories, pages 1--5, New York, NY, USA, 2005. ACM Press. Google Scholar
Digital Library
- Jinlin Yang, David Evans, Deepali Bhardwaj, Thirumalesh Bhat, and Manuvir Das. Perracotta: mining temporal API rules from imperfect traces. In ICSE '06: Proceeding of the 28th international conference on Software engineering, pages 282--291, New York, NY, USA, 2006. ACM Press. Google Scholar
Digital Library
Index Terms
Automatic inference of stationary fields: a generalization of java's final fields
Recommendations
Automatic inference of stationary fields: a generalization of java's final fields
POPL '08: Proceedings of the 35th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languagesJava programmers can document that the relationship between two objects is unchanging by declaring the field that encodes that relationship to be final. This information can be used in program understanding and detection of errors in new code additions. ...
Inference of field initialization
ICSE '11: Proceedings of the 33rd International Conference on Software EngineeringA raw object is partially initialized, with only some fields set to legal values. It may violate its object invariants, such as that a given field is non-null. Programs often manipulate partially-initialized objects, but they must do so with care. ...
Evaluating the Java Native Interface JNI: Leveraging Existing Native Code, Libraries and Threads to a Running Java Virtual Machine
This article aims to explore JNI features and to discover fundamental operations of the Java programming language, such as arrays, objects, classes, threads and exception handling, and to illustrate these by using various algorithms and code samples. ...







Comments