Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/1328438.1328463acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
research-article

Automatic inference of stationary fields: a generalization of java's final fields

Published: 07 January 2008 Publication History

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.

References

[1]
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.
[2]
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.
[3]
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.
[4]
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.
[5]
James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification, Third Edition. The Java Series. Addison-Wesley, Boston, Mass., 2005.
[6]
Samuel P. Harbison and Guy Steele. C, A Reference Manual. Prentice-Hall, Inc., New York, NY, 1987.
[7]
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.
[8]
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.
[9]
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.
[10]
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.
[11]
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.
[12]
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.
[13]
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.
[14]
A. Salcianu and M. Rinard. Purity and side effect analysis for Java programs. Lecture Notes in Computer Science, 3385:199--215, 2005.
[15]
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.
[16]
Dave Thomas, Chad Fowler, and Andy Hunt. Programming Ruby: The Pragmatic Programmer's Guide, Second Edition. Addison-Wesley, 2005.
[17]
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.
[18]
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.
[19]
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.
[20]
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.
[21]
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.

Cited By

View all
  • (2023)Design Pattern for Reusing Immutable Methods in Object-Oriented LanguagesProceedings of the 28th European Conference on Pattern Languages of Programs10.1145/3628034.3628040(1-9)Online publication date: 5-Jul-2023
  • (2023)A Cocktail Approach to Practical Call Graph ConstructionProceedings of the ACM on Programming Languages10.1145/36228337:OOPSLA2(1001-1033)Online publication date: 16-Oct-2023
  • (2017)SpencerProceedings of the 14th International Conference on Mining Software Repositories10.1109/MSR.2017.35(113-123)Online publication date: 20-May-2017
  • Show More Cited By

Index Terms

  1. Automatic inference of stationary fields: a generalization of java's final fields

        Recommendations

        Comments

        Information & Contributors

        Information

        Published In

        cover image ACM Conferences
        POPL '08: Proceedings of the 35th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
        January 2008
        448 pages
        ISBN:9781595936899
        DOI:10.1145/1328438
        • cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 43, Issue 1
          POPL '08
          January 2008
          420 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/1328897
          Issue’s Table of Contents
        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Sponsors

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        Published: 07 January 2008

        Permissions

        Request permissions for this article.

        Check for updates

        Author Tags

        1. Java
        2. final
        3. initialization
        4. stationary

        Qualifiers

        • Research-article

        Conference

        POPL08

        Acceptance Rates

        Overall Acceptance Rate 824 of 4,130 submissions, 20%

        Upcoming Conference

        POPL '25

        Contributors

        Other Metrics

        Bibliometrics & Citations

        Bibliometrics

        Article Metrics

        • Downloads (Last 12 months)5
        • Downloads (Last 6 weeks)1
        Reflects downloads up to 17 Oct 2024

        Other Metrics

        Citations

        Cited By

        View all
        • (2023)Design Pattern for Reusing Immutable Methods in Object-Oriented LanguagesProceedings of the 28th European Conference on Pattern Languages of Programs10.1145/3628034.3628040(1-9)Online publication date: 5-Jul-2023
        • (2023)A Cocktail Approach to Practical Call Graph ConstructionProceedings of the ACM on Programming Languages10.1145/36228337:OOPSLA2(1001-1033)Online publication date: 16-Oct-2023
        • (2017)SpencerProceedings of the 14th International Conference on Mining Software Repositories10.1109/MSR.2017.35(113-123)Online publication date: 20-May-2017
        • (2017)Detecting Full Initialization Points of Objects to Support Code Refactorings2017 24th Asia-Pacific Software Engineering Conference (APSEC)10.1109/APSEC.2017.17(110-119)Online publication date: Dec-2017
        • (2016)Exploring language support for immutabilityProceedings of the 38th International Conference on Software Engineering10.1145/2884781.2884798(736-747)Online publication date: 14-May-2016
        • (2016)Model-driven generation of runtime checks for system propertiesInternational Journal on Software Tools for Technology Transfer (STTT)10.1007/s10009-014-0325-218:1(1-19)Online publication date: 1-Feb-2016
        • (2016)Hybrid Analysis for Partial Order Reduction of Programs with ArraysProceedings of the 17th International Conference on Verification, Model Checking, and Abstract Interpretation - Volume 958310.1007/978-3-662-49122-5_14(291-310)Online publication date: 17-Jan-2016
        • (2016)Adaptable Runtime Monitoring for the Java Virtual MachineLeveraging Applications of Formal Methods, Verification and Validation: Discussion, Dissemination, Applications10.1007/978-3-319-47169-3_42(531-546)Online publication date: 5-Oct-2016
        • (2015)Model checking of concurrent programs with static analysis of field accessesScience of Computer Programming10.1016/j.scico.2014.10.00898:P4(735-763)Online publication date: 1-Feb-2015
        • (2013)Dynamic optimization of bytecode instrumentationProceedings of the 7th ACM workshop on Virtual machines and intermediate languages10.1145/2542142.2542145(21-30)Online publication date: 28-Oct-2013
        • Show More Cited By

        View Options

        Get Access

        Login options

        View options

        PDF

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader

        Media

        Figures

        Other

        Tables

        Share

        Share

        Share this Publication link

        Share on social media