Affiliation:
1. Cornell University, Ithaca, NY, USA
Abstract
This paper presents a type-based solution to the long-standing problem of object initialization. Constructors, the conventional mechanism for object initialization, have semantics that are surprising to programmers and that lead to bugs. They also contribute to the problem of null-pointer exceptions, which make software less reliable. Masked types are a new type-state mechanism that explicitly tracks the initialization state of objects and prevents reading from uninitialized fields. In the resulting language, constructors are ordinary methods that operate on uninitialized objects, and no special default value (null) is needed in the language. Initialization of cyclic data structures is achieved with the use of conditionally masked types. Masked types are modular and compatible with data abstraction. The type system is presented in a simplified object calculus and is proved to soundly prevent reading from uninitialized fields. Masked types have been implemented as an extension to Java, in which compilation simply erases extra type information. Experience using the extended language suggests that masked types work well on real code.
Publisher
Association for Computing Machinery (ACM)
Subject
Computer Graphics and Computer-Aided Design,Software
Cited by
23 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Initializing Global Objects: Time and Order;Proceedings of the ACM on Programming Languages;2023-10-16
2. A conceptual framework for safe object initialization: a principled and mechanized soundness proof of the Celsius model;Proceedings of the ACM on Programming Languages;2022-10-31
3. Relational nullable types with Boolean unification;Proceedings of the ACM on Programming Languages;2021-10-20
4. ιDOT: a DOT calculus with object initialization;Proceedings of the ACM on Programming Languages;2020-11-13
5. A type-and-effect system for object initialization;Proceedings of the ACM on Programming Languages;2020-11-13