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

Freedom before commitment: a lightweight type system for object initialisation

Published: 22 October 2011 Publication History

Abstract

One of the main purposes of object initialisation is to establish invariants such as a field being non-null or an immutable data structure containing specific values. These invariants are then implicitly assumed by the rest of the implementation, for instance, to ensure that a field may be safely dereferenced or that immutable data may be accessed concurrently. Consequently, letting an object escape from its constructor is dangerous; the escaping object might not yet satisfy its invariants, leading to errors in code that relies on them. Nevertheless, preventing objects entirely from escaping from their constructors is too restrictive; it is often useful to call auxiliary methods on the object under initialisation or to pass it to another constructor to set up mutually-recursive structures.
We present a type system that tracks which objects are fully initialised and which are still under initialisation. The system can be used to prevent objects from escaping, but also to allow safe escaping by making explicit which objects might not yet satisfy their invariants. We designed, formalised and implemented our system as an extension to a non-null type system, but it is not limited to this application. Our system is conceptually simple and requires little annotation overhead; it is sound and sufficiently expressive for many common programming idioms. Therefore, we believe it to be the first such system suitable for mainstream use.

References

[1]
PMD tool. http://pmd.sourceforge.net/, 2002.
[2]
C. Andreae, J. Noble, S. Markstrum, and T. Millstein. A framework for implementing pluggable type systems. In OOPSLA, pages 57--74. ACM, 2006.
[3]
M. Barnett and D. Naumann. Friends need a bit more: Maintaining invariants over shared state. In phMPC, volume 3125 of LNCS, pages 54--84. Springer, 2004.
[4]
G. Bracha. Pluggable type systems. In OOPSLA'04 Workshop on Revival of Dynamic Languages, 2004.
[5]
P. Chalin and P. R. James. Non-null references by default in Java: Alleviating the nullity annotation burden. In ECOOP, pages 227--247, 2007.
[6]
ECMA. ECMA-367: Eiffel analysis, design and programming language. ECMA, 2006.
[7]
T. Ekman and G. Hedin. Pluggable checking and inferencing of non-null types for Java. Journal of Object Technology, 6 (7), 2007.
[8]
T. Ekman and G. Hedin. The jastadd extensible Java compiler. In OOPSLA, pages 1--18. ACM, 2007.
[9]
M. D. Ernst and M. Ali. Building and using pluggable type systems. In FSE, pages 375--376. ACM, 2010.
[10]
M. Fahndrich and K. R. M. Leino. Declaring and checking non-null types in an object-oriented language. In OOPSLA, pages 302--312. ACM, 2003.
[11]
M. Fahndrich and S. Xia. Establishing object invariants with delayed types. In OOPSLA, pages 337--350. ACM, 2007.
[12]
C. Haack and E. Poll. Type-based object immutability with flexible initialization. In ECOOP, LNCS, pages 520--545. Springer, 2009.
[13]
L. Hubert. A non-null annotation inferencer for Java bytecode. In PASTE, pages 36--42. ACM, 2008.
[14]
L. Hubert, T. P. Jensen, and D. Pichardie. Semantic foundations and inference of non-null annotations. In FMOODS, pages 132--149, 2008.
[15]
K. R. M. Leino and P. Müller. Using the Spec# language, methodology, and tools to write bug-free programs. In LASER Summer School 2007/2008, volume 6029 of LNCS, pages 91--139. Springer, 2010.
[16]
C. Male, D. J. Pearce, A. Potanin, and C. Dymnikov. Java bytecode verification for @NonNull types. In CC, LNCS, pages 229--244. Springer, 2008.
[17]
B. Meyer. Attached types and their application to three open problems of object-oriented programming. In ECOOP, pages 1--32, 2005.
[18]
B. Meyer. Personal communication, 2011.
[19]
B. Meyer, A. Kogtenkov, and E. Stapf. Avoid a void: The eradication of null dereferencing. 2010.
[20]
M. M. Papi, M. Ali, T. L. Correa Jr., J. H. Perkins, and M. D. Ernst. Practical pluggable types for Java. In ISSTA, pages 201--212, 2008.
[21]
X. Qi and A. C. Myers. Masked types for sound object initialization. In POPL, pages 53--65, 2009.
[22]
F. Spoto and M. D. Ernst. Inference of field initialization. In ICSE'11, Waikiki, Hawaii, USA, May 25--27, 2011.
[23]
A. J. Summers and P. Müller. Freedom before commitment : Simple flexible initialisation for non-null types. Technical Report 716, ETH Zurich, 2011.
[24]
M. S. Tschantz and M. D. Ernst. Javari: adding reference immutability to Java. In OOPSLA. ACM, 2005.
[25]
Y. Zibin, A. Potanin, P. Li, M. Ali, and M. D. Ernst. Ownership and immutability in generic java. In OOPSLA '10, 2010.
[26]
Y. Zibin, D. Cunningham, I. Peshansky, and V. Saraswat. Object initialization in X10. In X10 Workshop, 2011.

Cited By

View all
  • (2023)Initializing Global Objects: Time and OrderProceedings of the ACM on Programming Languages10.1145/36228447:OOPSLA2(1310-1337)Online publication date: 16-Oct-2023
  • (2023)What Types Are Needed for Typing Dynamic Objects? A Python-Based Empirical StudyProgramming Languages and Systems10.1007/978-981-99-8311-7_2(24-45)Online publication date: 21-Nov-2023
  • (2022)A conceptual framework for safe object initialization: a principled and mechanized soundness proof of the Celsius modelProceedings of the ACM on Programming Languages10.1145/35633146:OOPSLA2(729-757)Online publication date: 31-Oct-2022
  • Show More Cited By

Index Terms

  1. Freedom before commitment: a lightweight type system for object initialisation

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    OOPSLA '11: Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applications
    October 2011
    1104 pages
    ISBN:9781450309400
    DOI:10.1145/2048066
    • cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 46, Issue 10
      OOPSLA '11
      October 2011
      1063 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2076021
      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: 22 October 2011

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. expressive
    2. initialisation
    3. modular
    4. non-null
    5. simple
    6. sound
    7. type-system

    Qualifiers

    • Research-article

    Conference

    SPLASH '11
    Sponsor:

    Acceptance Rates

    Overall Acceptance Rate 268 of 1,244 submissions, 22%

    Upcoming Conference

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)18
    • Downloads (Last 6 weeks)6
    Reflects downloads up to 13 Jan 2025

    Other Metrics

    Citations

    Cited By

    View all
    • (2023)Initializing Global Objects: Time and OrderProceedings of the ACM on Programming Languages10.1145/36228447:OOPSLA2(1310-1337)Online publication date: 16-Oct-2023
    • (2023)What Types Are Needed for Typing Dynamic Objects? A Python-Based Empirical StudyProgramming Languages and Systems10.1007/978-981-99-8311-7_2(24-45)Online publication date: 21-Nov-2023
    • (2022)A conceptual framework for safe object initialization: a principled and mechanized soundness proof of the Celsius modelProceedings of the ACM on Programming Languages10.1145/35633146:OOPSLA2(729-757)Online publication date: 31-Oct-2022
    • (2022)Wildcards need witness protectionProceedings of the ACM on Programming Languages10.1145/35633016:OOPSLA2(373-394)Online publication date: 31-Oct-2022
    • (2022)Containerless Plurals: Separating Number from Type in Object-Oriented ProgrammingACM Transactions on Programming Languages and Systems10.1145/352763544:4(1-56)Online publication date: 21-Sep-2022
    • (2021)Scalability and precision by combining expressive type systems and deductive verificationProceedings of the ACM on Programming Languages10.1145/34855205:OOPSLA(1-29)Online publication date: 15-Oct-2021
    • (2021)How Java Programmers Test Exceptional Behavior2021 IEEE/ACM 18th International Conference on Mining Software Repositories (MSR)10.1109/MSR52588.2021.00033(207-218)Online publication date: May-2021
    • (2020)ιDOT: a DOT calculus with object initializationProceedings of the ACM on Programming Languages10.1145/34282764:OOPSLA(1-28)Online publication date: 13-Nov-2020
    • (2020)A type-and-effect system for object initializationProceedings of the ACM on Programming Languages10.1145/34282434:OOPSLA(1-28)Online publication date: 13-Nov-2020
    • (2020)Verifying object constructionProceedings of the ACM/IEEE 42nd International Conference on Software Engineering10.1145/3377811.3380341(1447-1458)Online publication date: 27-Jun-2020
    • Show More Cited By

    View Options

    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