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.
- Kevin Bierhoff and Jonathan Aldrich. Modular typestate checking of aliased objects. In Proc. 22nd ACM Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA), pages 301--320, October 2007. Google Scholar
Digital Library
- Patrice Chalin and Perry James. Non-null references by default in Java: Alleviating the nullity annotation burden. In Proceedings of the 21st European Conference on Object-Oriented Programming, 2007. Google Scholar
Digital Library
- Sigmund Cherem and Radu Rugina. Maintaining doubly-linked list invariants in shape analysis with local reasoning. In Verification, Model Checking, and Abstract Interpretation, 8th International Conference (VMCAI 2007), Nice, France, January 2007. Google Scholar
Digital Library
- Robert DeLine and Manuel F¨ahndrich. Enforcing high-level protocols in low-level software. In Proc. SIGPLAN 2001 Conference on Programming Language Design and Implementation, pages 59--69, June 2001. Google Scholar
Digital Library
- Robert DeLine and Manuel Fähndrich. Typestates for objects. In Proceedings of 18th European Conference on Object-Oriented Programming (ECOOP'04), 2004.Google Scholar
Cross Ref
- Torbjörn Ekman and G¨orel Hedin. Pluggable checking and inferencing of non-null types for java. Journal of Object Technology, 6(9):455--475, October 2007.Google Scholar
Cross Ref
- Manuel Fähndrich and K. Rustan M. Leino. Declaring and checking non-null types in an object-oriented language. In Proc. 2003 ACM Conference on Object-Oriented Programming Systems, Languages, and Applications (OOSPLA), pages 302--312, October 2003. Google Scholar
Digital Library
- Manuel Fähndrich and K. Rustan M. Leino. Heap monotonic typestate. In Proceedings of the first International Workshop on Alias Confinement and Ownership (IWACO), July 2003.Google Scholar
- Manuel Fähndrich and Songtao Xia. Establishing object invariants with delayed types. In Proc. 22nd ACM Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA), October 2007. Google Scholar
Digital Library
- Stephen Fink, Eran Yahav, Nurit Dor, G. Ramalingam, and Emmanuel Geay. Effective typestate verification in the presence of aliasing. In ISSTA '06: Proceedings of the 2006 international symposium on Software testing and analysis, pages 133--144, 2006. Google Scholar
Digital Library
- Kathleen Fischer and John Reppy. The design of a class mechanism for Moby. In Proc. SIGPLAN 1999 Conference on Programming Language Design and Implementation, pages 37--49, 1999. Google Scholar
Digital Library
- James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification. Addison Wesley, 3rd edition, 2005. ISBN 0321246780. Google Scholar
Digital Library
- David Hovemeyer and William Pugh. Finding bugs is easy. In OOPSLA '04: Companion to the 19th annual ACM SIGPLAN conference on Object-oriented programming systems, languages, and applications, pages 132--136, 2004. Google Scholar
Digital Library
- David Hovemeyer, Jaime Spacco, and William Pugh. Evaluating and tuning a static analysis to find null pointer bugs. In PASTE '05: Proceedings of the 6th ACM SIGPLAN-SIGSOFT workshop on Program analysis for software tools and engineering, pages 13--19, 2005. Google Scholar
Digital Library
- Atsushi Igarashi and Benjamin C. Pierce. On inner classes. In Informal Proceedings of the Seventh International Workshop on Foundations of Object-Oriented Languages (FOOL 7), Boston, MA, January 2000.Google Scholar
Cross Ref
- ECMA International. Eiffel analysis, design and programming language. ECMA Standard 367, June 2005.Google Scholar
- Haskell 98: A non-strict, purely functional language, February 1999. Available at http://www.haskell.org/onlinereport/.Google Scholar
- Anita K. Jones and Barbara Liskov. A language extension for expressing constraints on data access. Comm. of the ACM, 21(5):358--367, May 1978. Google Scholar
Digital Library
- JSR 308: Annotations on Java Types. Available at http://groups.csail.mit.edu/pag/jsr308/.Google Scholar
- K. Rustan M. Leino. Data groups: specifying the modification of extended state. In Proc. 13th ACM Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA), pages 144--153, 1998. Google Scholar
Digital Library
- B. Liskov and J. Guttag. Data abstraction. In Abstraction and Specification in Program Development, chapter 4, pages 56--98. MIT Press and McGraw Hill, 1986.Google Scholar
- Barbara Liskov, Dorothy Curtis, Mark Day, Sanjay Ghemawat, Robert Gruber, Paul Johnson, and Andrew C. Myers. Theta Reference Manual. Programming Methodology Group Memo 88, MIT Laboratory for Computer Science, Cambridge, MA, February 1994. Available at http://www.pmg.lcs.mit.edu/papers/thetaref/.Google Scholar
- J. M. Lucassen and D. K. Gifford. Polymorphic effect systems. In Proc. 15th ACM Symp. on Principles of Programming Languages (POPL), pages 47--57, 1988. Google Scholar
Digital Library
- Robin Milner, Mads Tofte, and Robert Harper. The Definition of Standard ML. MIT Press, Cambridge, MA, 1990. Google Scholar
Digital Library
- Greg Morrisett, David Walker, Karl Crary, and Neal Glew. From System F to typed assembly language. ACM Transactions on Programming Languages and Systems, 21(3):528--569, May 1999. Google Scholar
Digital Library
- Nathaniel Nystrom, Michael R. Clarkson, and Andrew C. Myers. Polyglot: An extensible compiler framework for Java. In Proc. 12th International Compiler Construction Conference (CC'03), pages 138--152, April 2003. LNCS 2622. Google Scholar
Digital Library
- Xin Qi and Andrew C. Myers. Masked types. Technical report, Computer and Information Science, Cornell University, October 2008. http://hdl.handle.net/1813/11563.Google Scholar
- Joel Richardson, Peter Schwarz, and Luis-Felipe Cabrera. CACL: Efficient fine-grained protection for objects. In Proc. 1992 ACM Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 154--165, Vancouver, BC, Canada, October 1992. Google Scholar
Digital Library
- Amie L. Souter and Lori L. Pollock. The construction of contextual def-use associations for object-oriented systems. IEEE Trans. Softw. Eng., 29(11):1005--1018, 2003. Google Scholar
Digital Library
- Amie L. Souter, Lori L. Pollock, and Dixie Hisley. Inter-class def-use analysis with partial class representations. In PASTE '99: Proceedings of the 1999 ACM SIGPLAN-SIGSOFT workshop on Program analysis for software tools and engineering, pages 47--56, 1999. Google Scholar
Digital Library
- Robert E. Strom and Shaula Yemini. Typestate: A programming language concept for enhancing software reliability. IEEE Transactions on Software Engineering (TSE), 12(1):157--171, January 1986. Google Scholar
Digital Library
- Sun Microsystems. Java Language Specification, version 1.0 beta edition, October 1995. Available at ftp://ftp.javasoft.com/docs/javaspec.ps.zip.Google Scholar
- Don Syme. Initializing mutually referential abstract objects: The value recursion challenge. Electronic Notes in Theoretical Computer Science, 148(2):3--25, 2006. Google Scholar
Digital Library
- Reinhard Wilhelm, Shmuel Sagiv, and Thomas W. Reps. Shape analysis. In Proc. 9th International Compiler Construction Conference (CC'00), pages 1--17, 2000. Google Scholar
Digital Library
- Andrew K. Wright and Matthias Felleisen. A syntactic approach to type soundness. Information and Computation, 115(1):38--94, 1994. Google Scholar
Digital Library
Index Terms
Masked types for sound object initialization
Recommendations
Masked types for sound object initialization
POPL '09: Proceedings of the 36th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languagesThis 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 ...
Type inference for variant object types
FOOL VIIExisting type systems for object calculi are based on invariant subtyping. Subtyping invariance is required for soundness of static typing in the presence of method overrides, but it is often in the way of the expressive power of the type system. ...







Comments