Abstract
We present short programs that demonstrate the unsoundness of Java and Scala's current type systems. In particular, these programs provide parametrically polymorphic functions that can turn any type into any type without (down)casting. Fortunately, parametric polymorphism was not integrated into the Java Virtual Machine (JVM), so these examples do not demonstrate any unsoundness of the JVM. Nonetheless, we discuss broader implications of these findings on the field of programming languages.
- Nada Amin, Samuel Grütter, Martin Odersky, Tiark Rompf, and Sandro Stucki. The essence of dependent object types. In WadlerFest, 2016.Google Scholar
Cross Ref
- Nada Amin, Tiark Rompf, and Martin Odersky. Foundations of path-dependent types. In OOPSLA, 2014. Google Scholar
Digital Library
- Gavin M. Bierman, Matthew J. Parkinson, and Andrew M. Pitts. MJ: An imperative core calculus for Java and Java with effects. Technical report, University of Cambridge, April 2003.Google Scholar
- Gilad Bracha, Martin Odersky, David Stoutamire, and Philip Wadler. Making the future safe for the past: Adding genericity to the Java programming language. In OOPSLA, 1998. Google Scholar
Digital Library
- Andrey Breslav. The Kotlin language documentation, February 2016.Google Scholar
- Nicholas Cameron, Sophia Drossopoulou, and Erik Ernst. A model for Java with wildcards. In ECOOP, 2008. Google Scholar
Digital Library
- Peter S. Canning, William R. Cook, Walter L. Hill, Walter G. Olthoff, and John C. Mitchell. F-bounded polymorphism for object-oriented programming. In FPCA, 1989. Google Scholar
Digital Library
- William R. Cook. A proposal for making Eiffel type-safe. The Computer Journal, 32(4):305–311, August 1989. Google Scholar
Digital Library
- Sophia Drossopoulou, Susan Eisenbach, and Sarfraz Khurshid. Is the Java type system sound? TAPOS, 5(1):3–24, January 1999. Google Scholar
Digital Library
- Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. Classes and mixins. In POPL, 1998. Google Scholar
Digital Library
- Michael Gordon, Arthur L. Miller, and Christopher P. Wadsworth. Edinburgh LCF: A mechanised logic of computation. LNCS, 78, 1979.Google Scholar
- James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java™ Language Specification. Addison-Wesley Professional, third edition, 2005. Google Scholar
Digital Library
- Ben Greenman, Fabian Muehlboeck, and Ross Tate. Getting F-bounded polymorphism into shape. In PLDI, 2014. Google Scholar
Digital Library
- Radu Grigore. Java generics are Turing complete. arXiv, 2016.Google Scholar
- Dan Grossman. Existential types for imperative languages. In ESOP, 2002. Google Scholar
Digital Library
- Fritz Henglein. Type inference with polymorphic recursion. TOPLAS, 15(2):253–289, April 1993. Google Scholar
Digital Library
- Tony C. Hoare. Null references: The billion dollar mistake. QCon, March 2009.Google Scholar
- Atsushi Igarashi, Benjamin C. Pierce, and Philip Wadler. Featherweight Java: A minimal core calculus for Java and GJ. TOPLAS, 23(3):396–450, May 2001. Google Scholar
Digital Library
- Atsushi Igarashi and Mirko Viroli. On variance-based subtyping for parametric types. In ECOOP, 2002. Google Scholar
Digital Library
- Andrew J. Kennedy and Benjamin C. Pierce. On decidability of nominal subtyping with variance. In FOOL, 2007.Google Scholar
- Assaf J. Kfoury, Jerzy Tiuryn, and Pawel Urzyczyn. Computational consequences and partial solutions of a generalized unification problem. In LICS, 1989. Google Scholar
Digital Library
- Gavin King. The Ceylon language specification, version 1.0, November 2013.Google Scholar
- Lambert Meertens. Incremental polymorphic type checking in B. In POPL, 1983. Google Scholar
Digital Library
- Bertrand Meyer. Genericity versus inheritance. In OOPSLA, 1986. Google Scholar
Digital Library
- Alan Mycroft. Polymorphic type schemes and recursive definitions. In International Symposium on Programming, 1984. Google Scholar
Digital Library
- Tobias Nipkow and David von Oheimb. Java light is type-safe — definitely. In POPL, 1998. Google Scholar
Digital Library
- Martin Odersky. The Scala language specification, version 2.9, May 2010.Google Scholar
- Benjamin C. Pierce. Bounded quantification is undecidable. In POPL, 1992. Google Scholar
Digital Library
- Andrew M. Pitts. Nominal logic, a first order theory of names and binding. Information and Computation, 186(2):165–193, 2003. Google Scholar
Digital Library
- Tiark Rompf and Nada Amin. From F to DOT: Type soundness proofs with definitional interpreters. Technical report, Purdue University, October 2015.Google Scholar
- The Rust Community. The Rust programming language, May 2015.Google Scholar
- Dan Smith. Possibly modify well-formedness restriction for wildcards?, August 2014.Google Scholar
- https://bugs.openjdk.java.net/browse/JDK-8054941.Google Scholar
- Christopher Strachey. Fundamental concepts in programming languages. Lecture Notes for the International Summer School in Computer Programming, August 1967.Google Scholar
- Alexander J. Summers. Modelling Java requires state. In FTfJP, 2009. Google Scholar
Digital Library
- Ross Tate, Alan Leung, and Sorin Lerner. Taming wildcards in Java’s type system. In PLDI, 2011. Google Scholar
Digital Library
- Kresten Krab Thorup and Mads Torgersen. Unifying genericity: Combining the benefits of virtual types and parameterized classes. In ECOOP, 1999. Google Scholar
Digital Library
- Mads Tofte. Type inference for polymorphic references. Information and Computation, 89(1):1–34, 1990. Google Scholar
Digital Library
- Mads Torgersen, Erik Ernst, and Christian Plesner Hansen. Wild FJ. In FOOL, 2005.Google Scholar
- Mads Torgersen, Christian Plesner Hansen, Erik Ernst, Peter von der Ahé, Gilad Bracha, and Neal Gafter. Adding wildcards to the Java programming language. In Symposium on Applied Computing, 2004. Google Scholar
Digital Library
- Geoffrey Alan Washburn. Another type soundness hole, December 2008.Google Scholar
- https://issues.scala-lang.org/browse/SI-1557.Google Scholar
Index Terms
Java and scala's type systems are unsound: the existential crisis of null pointers
Recommendations
Java and scala's type systems are unsound: the existential crisis of null pointers
OOPSLA 2016: Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and ApplicationsWe present short programs that demonstrate the unsoundness of Java and Scala's current type systems. In particular, these programs provide parametrically polymorphic functions that can turn any type into any type without (down)casting. Fortunately, ...
Compile-time type-checking for custom type qualifiers in Java
OOPSLA '07: Companion to the 22nd ACM SIGPLAN conference on Object-oriented programming systems and applications companionWe have created a system that enables programmers to add custom type qualifiers to the Java language in a backward-compatible way. The system allows programmers to write type qualifiers in their programs and to create compiler plug-ins that enforce the ...
Compile-time type-checking for custom type qualifiers in Java
OOPSLA '07: Companion to the 22nd ACM SIGPLAN conference on Object-oriented programming systems and applications companionWe have created a system that enables programmers to add custom type qualifiers to the Java language in a backward-compatible way. The system allows programmers to write type qualifiers in their programs and to create compiler plug-ins that enforce the ...







Comments