skip to main content

A conceptual framework for safe object initialization: a principled and mechanized soundness proof of the Celsius model

Published:31 October 2022Publication History
Skip Abstract Section

Abstract

An object under initialization does not fulfill its class specification yet and can be unsafe to use as it may have uninitialized fields. It can sometimes be useful to call methods on such a partially initialized object in order to compute a complex initial value, or to let the object escape its constructor in order to create mutually recursive objects. However, inadvertent usage of uninitialized fields can lead to run-time crashes. Those subtle programming errors are not statically detected by most modern compilers.

While many other features of object-oriented programming languages have been thoroughly studied over the years, object initialization lacks a simple, systematic, and principled treatment. Building on the insights of previous work, we identify a set of four core principles for safe initialization: monotonicity, authority, stackability, and scopability. We capture the essence of the principles with a minimal calculus, Celsius, and show that the principles give rise to a practical initialization system that strikes a balance between expressiveness and simplicity. The meta-theory of the system is entirely mechanized using the Coq proof assistant. We believe that our approach based on well-identified core principles sheds new light on the underlying mechanisms ensuring safety and could serve as a basis for language design when faced with similar challenges.

References

  1. Nada Amin, Samuel Grütter, Martin Odersky, Tiark Rompf, and Sandro Stucki. 2016. The essence of dependent object types. In A List of Successes That Can Change the World. Springer, 249–272. Google ScholarGoogle Scholar
  2. Nada Amin and Tiark Rompf. 2017. Type soundness proofs with definitional interpreters. Pages: 666–679 Publisher: ACM Google ScholarGoogle Scholar
  3. Clément Blaudeau. 2022. clementblaudeau/celsius: OOPSLA 2022 Artifact. https://doi.org/10.5281/zenodo.7079830 Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Vincent Cremet and Philippe Altherr. 2008. Adding Type Constructor Parameterization to Java. J. Object Technol., 7, 5 (2008), 25–65. https://doi.org/10.5381/jot.2008.7.5.a2 Google ScholarGoogle ScholarCross RefCross Ref
  5. Benjamin Delaware, William R. Cook, and Don S. Batory. 2011. Product lines of theorems. In Proceedings of the 26th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2011, part of SPLASH 2011, Portland, OR, USA, October 22 - 27, 2011, Cristina Videira Lopes and Kathleen Fisher (Eds.). ACM, 595–608. https://doi.org/10.1145/2048066.2048113 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Manuel Fähndrich and K. Rustan M. Leino. 2003. Declaring and checking non-null types in an object-oriented language. In OOPSLA. Google ScholarGoogle Scholar
  7. Manuel Fahndrich and Rustan Leino. 2003. Heap Monotonic Typestate. https://www.microsoft.com/en-us/research/publication/heap-monotonic-typestate/ Google ScholarGoogle Scholar
  8. Manuel Fähndrich and Songtao Xia. 2007. Establishing object invariants with delayed types. In Proceedings of the 22nd Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2007, October 21-25, 2007, Montreal, Quebec, Canada, Richard P. Gabriel, David F. Bacon, Cristina Videira Lopes, and Guy L. Steele Jr. (Eds.). ACM, 337–350. https://doi.org/10.1145/1297027.1297052 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. James Gosling, Bill Joy, Guy Steele, Gilad Bracha, and Alex Buckley. 2015. The Java Language Specification, Java SE 8 Edition. Google ScholarGoogle Scholar
  10. Tom Hirschowitz, Xavier Leroy, and Joe B. Wells. 2003. Compilation of extended recursion in call-by-value functional languages. Higher-Order and Symbolic Computation, 22 (2003), 3–66. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Ifaz Kabir, Yufeng Li, and Ondrej Lhoták. 2020. ι DOT: a DOT calculus with object initialization. Proc. ACM Program. Lang., 4, OOPSLA (2020), 208:1–208:28. https://doi.org/10.1145/3428276 Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Fengyun Liu, Ondřej Lhoták, Aggelos Biboudis, Paolo G. Giarrusso, and Martin Odersky. 2020. A type-and-effect system for object initialization. 4 (2020), 1–28. issn:2475-1421 https://doi.org/10.1145/3428243 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Fengyun Liu, Ondřej Lhoták, Enze Xing, and Nguyen Cao Pham. 2021. Safe object initialization, abstractly. In Proceedings of the 12th ACM SIGPLAN International Symposium on Scala. Association for Computing Machinery, 33–43. isbn:978-1-4503-9113-9 https://doi.org/10.1145/3486610.3486895 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. John M. Lucassen and David K. Gifford. 1988. Polymorphic Effect Systems. In Conference Record of the Fifteenth Annual ACM Symposium on Principles of Programming Languages, San Diego, California, USA, January 10-13, 1988, Jeanne Ferrante and Peter Mager (Eds.). ACM Press, 47–57. https://doi.org/10.1145/73560.73564 Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Julian Mackay, Hannes Mehnert, Alex Potanin, Lindsay J. Groves, and Nicholas Robert Cameron. 2012. Encoding Featherweight Java with assignment and immutability using the Coq proof assistant. In [email protected]. Google ScholarGoogle Scholar
  16. Mark Samuel Miller. 2006. Robust Composition: Towards a Unified Approach to Access Control and Concurrency Control. Ph. D. Dissertation. Johns Hopkins University. Baltimore, Maryland, USA. Google ScholarGoogle Scholar
  17. Abel Nieto, Yaoyu Zhao, Ondrej Lhoták, Angela Chang, and Justin Pu. 2020. Scala with Explicit Nulls. In 34th European Conference on Object-Oriented Programming, ECOOP 2020, November 15-17, 2020, Berlin, Germany (Virtual Conference), Robert Hirschfeld and Tobias Pape (Eds.) (LIPIcs, Vol. 166). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 25:1–25:26. https://doi.org/10.4230/LIPIcs.ECOOP.2020.25 Google ScholarGoogle ScholarCross RefCross Ref
  18. Martin Odersky. 2019. Scala Language Specification. https://scala-lang.org/files/archive/spec/2.13/ Google ScholarGoogle Scholar
  19. Corneliu Popeea, Dana N. Xu, and Wei-Ngan Chin. 2008. A practical and precise inference and specializer for array bound checks elimination. In Proceedings of the 2008 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation, PEPM 2008, San Francisco, California, USA, January 7-8, 2008, Robert Glück and Oege de Moor (Eds.). ACM, 177–187. https://doi.org/10.1145/1328408.1328434 Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Xin Qi and Andrew C. Myers. 2009. Masked types for sound object initialization. In Proceedings of the 36th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2009, Savannah, GA, USA, January 21-23, 2009, Zhong Shao and Benjamin C. Pierce (Eds.). ACM, 53–65. https://doi.org/10.1145/1480881.1480890 Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Alban Reynaud, Gabriel Scherer, and Jeremy Yallop. 2021. A practical mode system for recursive definitions. 5 (2021), 45:1–45:29. https://doi.org/10.1145/3434326 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Tiark Rompf and Nada Amin. 2016. Type soundness for dependent object types (DOT). Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Marco Servetto, Julian Mackay, Alex Potanin, and James W Noble. 2013. The Billion-Dollar Fix - Safe Modular Circular Initialisation with Placeholders and Placeholder Types. In ECOOP. Google ScholarGoogle Scholar
  24. Robert E. Strom and Shaula Yemini. 1986. Typestate: A programming language concept for enhancing software reliability. IEEE Transactions on Software Engineering, SE-12 (1986), 157–171. Google ScholarGoogle Scholar
  25. Alexander J. Summers and Peter Mueller. 2011. Freedom before commitment: a lightweight type system for object initialisation. In Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applications (OOPSLA ’11). Association for Computing Machinery, 1013–1032. isbn:978-1-4503-0940-0 https://doi.org/10.1145/2048066.2048142 Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Alexander J Summers and Peter Müller. 2010. Freedom before commitment: Simple flexible initialisation for non-null types. Technical Report, 716 (2010), https://www.research-collection.ethz.ch/handle/20.500.11850/153153 Google ScholarGoogle Scholar
  27. Don Syme. 2006. Initializing Mutually Referential Abstract Objects: The Value Recursion Challenge. Electron. Notes Theor. Comput. Sci., 148, 2 (2006), 3–25. https://doi.org/10.1016/j.entcs.2005.11.038 Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Yoav Zibin, David Cunningham, Igor Peshansky, and Vijay Saraswat. 2012. Object initialization in X10. In European Conference on Object-Oriented Programming. 207–231. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A conceptual framework for safe object initialization: a principled and mechanized soundness proof of the Celsius model

            Recommendations

            Comments

            Login options

            Check if you have access through your login credentials or your institution to get full access on this article.

            Sign in

            Full Access

            • Article Metrics

              • Downloads (Last 12 months)149
              • Downloads (Last 6 weeks)18

              Other Metrics

            PDF Format

            View or Download as a PDF file.

            PDF

            eReader

            View online with eReader.

            eReader
            About Cookies On This Site

            We use cookies to ensure that we give you the best experience on our website.

            Learn more

            Got it!