skip to main content
research-article
Public Access

Java and scala's type systems are unsound: the existential crisis of null pointers

Published:19 October 2016Publication History
Skip Abstract Section

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.

References

  1. Nada Amin, Samuel Grütter, Martin Odersky, Tiark Rompf, and Sandro Stucki. The essence of dependent object types. In WadlerFest, 2016.Google ScholarGoogle ScholarCross RefCross Ref
  2. Nada Amin, Tiark Rompf, and Martin Odersky. Foundations of path-dependent types. In OOPSLA, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle Scholar
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. Andrey Breslav. The Kotlin language documentation, February 2016.Google ScholarGoogle Scholar
  6. Nicholas Cameron, Sophia Drossopoulou, and Erik Ernst. A model for Java with wildcards. In ECOOP, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. William R. Cook. A proposal for making Eiffel type-safe. The Computer Journal, 32(4):305–311, August 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Sophia Drossopoulou, Susan Eisenbach, and Sarfraz Khurshid. Is the Java type system sound? TAPOS, 5(1):3–24, January 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. Classes and mixins. In POPL, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Michael Gordon, Arthur L. Miller, and Christopher P. Wadsworth. Edinburgh LCF: A mechanised logic of computation. LNCS, 78, 1979.Google ScholarGoogle Scholar
  12. James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java™ Language Specification. Addison-Wesley Professional, third edition, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Ben Greenman, Fabian Muehlboeck, and Ross Tate. Getting F-bounded polymorphism into shape. In PLDI, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Radu Grigore. Java generics are Turing complete. arXiv, 2016.Google ScholarGoogle Scholar
  15. Dan Grossman. Existential types for imperative languages. In ESOP, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Fritz Henglein. Type inference with polymorphic recursion. TOPLAS, 15(2):253–289, April 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Tony C. Hoare. Null references: The billion dollar mistake. QCon, March 2009.Google ScholarGoogle Scholar
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. Atsushi Igarashi and Mirko Viroli. On variance-based subtyping for parametric types. In ECOOP, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Andrew J. Kennedy and Benjamin C. Pierce. On decidability of nominal subtyping with variance. In FOOL, 2007.Google ScholarGoogle Scholar
  21. Assaf J. Kfoury, Jerzy Tiuryn, and Pawel Urzyczyn. Computational consequences and partial solutions of a generalized unification problem. In LICS, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Gavin King. The Ceylon language specification, version 1.0, November 2013.Google ScholarGoogle Scholar
  23. Lambert Meertens. Incremental polymorphic type checking in B. In POPL, 1983. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Bertrand Meyer. Genericity versus inheritance. In OOPSLA, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Alan Mycroft. Polymorphic type schemes and recursive definitions. In International Symposium on Programming, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Tobias Nipkow and David von Oheimb. Java light is type-safe — definitely. In POPL, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Martin Odersky. The Scala language specification, version 2.9, May 2010.Google ScholarGoogle Scholar
  28. Benjamin C. Pierce. Bounded quantification is undecidable. In POPL, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Andrew M. Pitts. Nominal logic, a first order theory of names and binding. Information and Computation, 186(2):165–193, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Tiark Rompf and Nada Amin. From F to DOT: Type soundness proofs with definitional interpreters. Technical report, Purdue University, October 2015.Google ScholarGoogle Scholar
  31. The Rust Community. The Rust programming language, May 2015.Google ScholarGoogle Scholar
  32. Dan Smith. Possibly modify well-formedness restriction for wildcards?, August 2014.Google ScholarGoogle Scholar
  33. https://bugs.openjdk.java.net/browse/JDK-8054941.Google ScholarGoogle Scholar
  34. Christopher Strachey. Fundamental concepts in programming languages. Lecture Notes for the International Summer School in Computer Programming, August 1967.Google ScholarGoogle Scholar
  35. Alexander J. Summers. Modelling Java requires state. In FTfJP, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Ross Tate, Alan Leung, and Sorin Lerner. Taming wildcards in Java’s type system. In PLDI, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Kresten Krab Thorup and Mads Torgersen. Unifying genericity: Combining the benefits of virtual types and parameterized classes. In ECOOP, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Mads Tofte. Type inference for polymorphic references. Information and Computation, 89(1):1–34, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Mads Torgersen, Erik Ernst, and Christian Plesner Hansen. Wild FJ. In FOOL, 2005.Google ScholarGoogle Scholar
  40. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  41. Geoffrey Alan Washburn. Another type soundness hole, December 2008.Google ScholarGoogle Scholar
  42. https://issues.scala-lang.org/browse/SI-1557.Google ScholarGoogle Scholar

Index Terms

  1. Java and scala's type systems are unsound: the existential crisis of null pointers

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 51, Issue 10
        OOPSLA '16
        October 2016
        915 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/3022671
        Issue’s Table of Contents
        • cover image ACM Conferences
          OOPSLA 2016: Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications
          October 2016
          915 pages
          ISBN:9781450344449
          DOI:10.1145/2983990

        Copyright © 2016 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 19 October 2016

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!