skip to main content
research-article
Open access

ιDOT: a DOT calculus with object initialization

Published: 13 November 2020 Publication History

Abstract

The Dependent Object Types (DOT) calculus serves as a foundation of the Scala programming language, with a machine-verified soundness proof. However, Scala's type system has been shown to be unsound due to null references, which are used as default values of fields of objects before they have been initialized. This paper proposes ιDOT, an extension of DOT for ensuring safe initialization of objects. DOT was previously extended to κDOT with the addition of mutable fields and constructors. To κDOT, ιDOT adds an initialization effect system that statically prevents the possibility of reading a null reference from an uninitialized object. To design ιDOT, we have reformulated the Freedom Before Commitment object initialization scheme in terms of disjoint subheaps to make it easier to formalize in an effect system and prove sound. Soundness of ιDOT depends on the interplay of three systems of rules: a type system close to that of DOT, an effect system to ensure definite assignment of fields in each constructor, and an initialization system that tracks the initialization status of objects in a stack of subheaps. We have proven the overall system sound and verified the soundness proof using the Coq proof assistant.

Supplementary Material

Auxiliary Presentation Video (oopsla20main-p386-p-video.mp4)
This is the video of the presentation of our OOPSLA'20 paper on ιDOT: A DOT Calculus with Object Initialization. The Dependent Object Types (DOT) calculus serves as a foundation of the Scala programming language. However, Scala's type system has been shown to be unsound due to null references, which are used as default values of fields of objects before they have been initialized. Previous DOT calculi have sidestepped having null references by pre-populating fields. Our paper proposes ιDOT, an extension of DOT with safe initialization of objects. ιDOT adds an initialization effect system that statically prevents the possibility of reading a null reference from an uninitialized object. Soundness of ιDOT depends on the interplay of three systems: a type system close to that of DOT, an effect system to ensure definite assignment of fields in each constructor, and an initialization system that tracks the initialization status of objects.

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-Essays Dedicated to Philip Wadler on the Occasion of His 60th Birthday (Lecture Notes in Computer Science, Vol. 9600 ), Sam Lindley, Conor McBride, Philip W. Trinder, and Donald Sannella (Eds.). Springer, Cham, 249-272. https://doi.org/10.1007/978-3-319-30936-1_14
[2]
Nada Amin, Tiark Rompf, and Martin Odersky. 2014. Foundations of Path-Dependent Types. In Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications, OOPSLA 2014, part of SPLASH 2014, Portland, OR, USA, October 20-24, 2014, Andrew P. Black and Todd D. Millstein (Eds.). ACM, New York, NY, USA, 233-249. https://doi.org/10.1145/2660193.2660216
[3]
Nada Amin and Ross Tate. 2016. Java and Scala's Type Systems Are Unsound: The Existential Crisis of Null Pointers. In Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications (Amsterdam, Netherlands) ( OOPSLA 2016). ACM, New York, NY, USA, 838-848. https://doi.org/10.1145/ 2983990.2984004
[4]
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 and Applications (Montreal, Quebec, Canada) ( OOPSLA '07). ACM, New York, NY, USA, 337-350. https://doi.org/10.1145/1297027.1297052
[5]
Matthias Felleisen and Daniel P. Friedman. 1987. A Calculus for Assignments in Higher-Order Languages. In Conference Record of the Fourteenth Annual ACM Symposium on Principles of Programming Languages, Munich, Germany, January 21-23, 1987. ACM Press, New York, NY, USA, 314-325. https://doi.org/10.1145/41625.41654
[6]
Christian Haack and Erik Poll. 2009. Type-Based Object Immutability with Flexible Initialization. In ECOOP 2009-ObjectOriented Programming, 23rd European Conference, Genoa, Italy, July 6-10, 2009. Proceedings (Lecture Notes in Computer Science, Vol. 5653 ), Sophia Drossopoulou (Ed.). Springer, Berlin, Heidelberg, 520-545. https://doi.org/10.1007/978-3-642-03013-0_24
[7]
Ifaz Kabir and Ondřej Lhoták. 2018. DOT: Scaling DOT with Mutation and Constructors. In Proceedings of the 9th ACM SIGPLAN International Symposium on Scala (St. Louis, MO, USA) ( Scala 2018 ). ACM, New York, NY, USA, 40-50. https://doi.org/10.1145/3241653.3241659
[8]
Ifaz Kabir, Yufeng Li, and Ondřej Lhoták. 2020. DOT: A DOT Calculus with Object Initialization. Technical Report CS-2020-06. University of Waterloo. https://cs.uwaterloo.ca/sites/ca.computer-science/files/uploads/files/cs-2020-06.pdf
[9]
Martin Odersky, Philippe Altherr, Vincent Cremet, Iulian Dragos, Gilles Dubochet, Burak Emir, Sean McDirmid, Stéphane Micheloud, Nikolay Mihaylov, Michel Schinz, Lex Spoon, Erik Stenman, and Matthias Zenger. 2006. An Overview of the Scala Programming Language (2. Edition). ( 2006 ). http://infoscience.epfl.ch/record/ 85634
[10]
Xin Qi and Andrew C. Myers. 2009. Masked Types for Sound Object Initialization. In Proceedings of the 36th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (Savannah, GA, USA) ( POPL '09). ACM, New York, NY, USA, 53-65. https://doi.org/10.1145/1480881.1480890
[11]
Marianna Rapoport, Ifaz Kabir, Paul He, and Ondřej Lhoták. 2017. A Simple Soundness Proof for Dependent Object Types. Proc. ACM Program. Lang. 1, OOPSLA, Article 46 (Oct. 2017 ), 27 pages. https://doi.org/10.1145/3133870
[12]
Marianna Rapoport and Ondřej Lhoták. 2019. A Path to DOT: Formalizing Fully Path-dependent Types. Proc. ACM Program. Lang. 3, OOPSLA, Article 145 (Oct. 2019 ), 29 pages. https://doi.org/10.1145/3360571
[13]
Tiark Rompf and Nada Amin. 2016. Type Soundness for Dependent Object Types (DOT). In Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2016, part of SPLASH 2016, Amsterdam, The Netherlands, October 30-November 4, 2016, Eelco Visser and Yannis Smaragdakis (Eds.). ACM, New York, NY, USA, 624-641. https://doi.org/10.1145/2983990.2984008
[14]
Marco Servetto, Julian Mackay, Alex Potanin, and James Noble. 2013. The Billion-Dollar Fix-Safe Modular Circular Initialisation with Placeholders and Placeholder Types. In ECOOP 2013-Object-Oriented Programming-27th European Conference, Montpellier, France, July 1-5, 2013. Proceedings (Lecture Notes in Computer Science, Vol. 7920 ), Giuseppe Castagna (Ed.). Springer, Berlin, Heidelberg, 205-229. https://doi.org/10.1007/978-3-642-39038-8_9
[15]
Peter Sestoft. 1997. Deriving a Lazy Abstract Machine. Journal of Functional Programming 7, 3 (May 1997 ), 231-264. https://doi.org/10.1017/S0956796897002712
[16]
Alexander J. Summers and Peter Mueller. 2011a. Freedom Before Commitment : Simple Flexible Initialisation for Non-Null Types. Technical Report 716. ETH Zurich.
[17]
Alexander J. Summers and Peter Mueller. 2011b. 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 (Portland, Oregon, USA) ( OOPSLA '11). ACM, New York, NY, USA, 1013-1032. https://doi.org/10.1145/ 2048066.2048142
[18]
Andrew K. Wright and Matthias Felleisen. 1994. A Syntactic Approach to Type Soundness. Information and Computation 115, 1 ( 1994 ), 38-94. https://doi.org/10.1006/inco. 1994.1093

Cited By

View all
  • (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
  • (2021)Reachability types: tracking aliasing and separation in higher-order functional programsProceedings of the ACM on Programming Languages10.1145/34855165:OOPSLA(1-32)Online publication date: 15-Oct-2021

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 4, Issue OOPSLA
November 2020
3108 pages
EISSN:2475-1421
DOI:10.1145/3436718
Issue’s Table of Contents
This work is licensed under a Creative Commons Attribution International 4.0 License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 13 November 2020
Published in PACMPL Volume 4, Issue OOPSLA

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. DOT
  2. Scala
  3. dependent objects
  4. initialization
  5. type safety

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)139
  • Downloads (Last 6 weeks)20
Reflects downloads up to 21 Sep 2024

Other Metrics

Citations

Cited By

View all
  • (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
  • (2021)Reachability types: tracking aliasing and separation in higher-order functional programsProceedings of the ACM on Programming Languages10.1145/34855165:OOPSLA(1-32)Online publication date: 15-Oct-2021

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media