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.
- 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 Scholar
- Nada Amin and Tiark Rompf. 2017. Type soundness proofs with definitional interpreters. Pages: 666–679 Publisher: ACM
Google Scholar
- Clément Blaudeau. 2022. clementblaudeau/celsius: OOPSLA 2022 Artifact. https://doi.org/10.5281/zenodo.7079830
Google Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- Manuel Fähndrich and K. Rustan M. Leino. 2003. Declaring and checking non-null types in an object-oriented language. In OOPSLA.
Google Scholar
- Manuel Fahndrich and Rustan Leino. 2003. Heap Monotonic Typestate. https://www.microsoft.com/en-us/research/publication/heap-monotonic-typestate/
Google Scholar
- 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 Scholar
Digital Library
- James Gosling, Bill Joy, Guy Steele, Gilad Bracha, and Alex Buckley. 2015. The Java Language Specification, Java SE 8 Edition.
Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
- 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 Scholar
Cross Ref
- Martin Odersky. 2019. Scala Language Specification. https://scala-lang.org/files/archive/spec/2.13/
Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- Yoav Zibin, David Cunningham, Igor Peshansky, and Vijay Saraswat. 2012. Object initialization in X10. In European Conference on Object-Oriented Programming. 207–231.
Google Scholar
Digital Library
Index Terms
A conceptual framework for safe object initialization: a principled and mechanized soundness proof of the Celsius model
Recommendations
A Mechanised Proof of Gödel's Incompleteness Theorems Using Nominal Isabelle
An Isabelle/HOL formalisation of Gödel's two incompleteness theorems is presented. The work follows wierczkowski's detailed proof of the theorems using hereditarily finite (HF) set theory (Dissertationes Mathematicae 422, 1---58, 2003). Avoiding the ...
Completeness and decidability of converse PDL in the constructive type theory of Coq
CPP 2018: Proceedings of the 7th ACM SIGPLAN International Conference on Certified Programs and ProofsThe completeness proofs for Propositional Dynamic Logic (PDL) in the literature are non-constructive and usually presented in an informal manner. We obtain a formal and constructive completeness proof for Converse PDL by recasting a completeness proof ...
Proof Reflection in Coq
We formalize natural deduction for first-order logic in the proof assistant Coq, using de Bruijn indices for variable binding. The main judgment we model is of the form Γ⊢d [:] ϕ, stating that d is a proof term of formula ϕ under hypotheses Γ; it can be ...






Comments