skip to main content
research-article

Java generics are turing complete

Published:01 January 2017Publication History
Skip Abstract Section

Abstract

This paper describes a reduction from the halting problem of Turing machines to subtype checking in Java. It follows that subtype checking in Java is undecidable, which answers a question posed by Kennedy and Pierce in 2007. It also follows that Java's type checker can recognize any recursive language, which improves a result of Gill and Levy from 2016. The latter point is illustrated by a parser generator for fluent interfaces.

References

  1. N. Amin and R. Tate. Java and Scala’s type systems are unsound: The existential crisis of null pointers. In OOPSLA, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. R. O. Bjarnason. More Scala typehackery. https://apocalisp.wordpress.com/2009/09/02/ (see also https://michid.wordpress.com/2010/01/29), 2009.Google ScholarGoogle Scholar
  3. A. Breslav. Mixed-site variance in Kotlin. http://blog.jetbrains.com/kotlin/2013/06/mixed, 2013.Google ScholarGoogle Scholar
  4. B. Courcelle. On jump-deterministic pushdown automata. Mathematical Systems Theory, 1977.Google ScholarGoogle Scholar
  5. L. Dionne. Boost.Hana. http://boostorg.github.io/hana, 2016.Google ScholarGoogle Scholar
  6. Y. Gil and T. Levy. Formal language recognition with the Java type checker. In ECOOP, 2016.Google ScholarGoogle Scholar
  7. O. Goldreich. Computational complexity: a conceptual perspective. Cambridge University Press, 2008. Google ScholarGoogle ScholarCross RefCross Ref
  8. J. Gosling, B. Joy, G. Steele, G. Bracha, and A. Buckley. The Java language specification, 2015. Java SE 8 Edition. B. Greenman, F. Muehlboeck, and R. Tate. Getting F-bounded polymorphism into shape. In PLDI, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. R. Grigore. Parser generator for fluent interfaces. http://rgrig.appspot.com/javats, 2016.Google ScholarGoogle Scholar
  10. J. E. Hopcroft and J. D. Ullman. Introduction to Automata Theory, Languages, and Computation. Addison–Wesley, 1979. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. A. J. Kennedy and B. Pierce. On decidability of nominal subtyping with variance. In FOOL, 2007.Google ScholarGoogle Scholar
  12. D. E. Knuth. On the translation of languages from left to right. Information and Control, 1965.Google ScholarGoogle ScholarCross RefCross Ref
  13. M. Lange and H. Leiß. To CNF or not to CNF? An efficient yet presentable version of the CYK algorithm. Informatica Didactica, 2009.Google ScholarGoogle Scholar
  14. X. Leroy. Formal verification of a realistic compiler. CACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. M. Lillibridge. Translucent Sums: A Foundation for Higher-Order Modules. PhD thesis, CMU, 1997.Google ScholarGoogle Scholar
  16. E. Lippert. A simple problem whose decidability is not known. Theoretical Computer Science Stack Exchange, 2013. http://cstheory.stackexchange.com/q/18866.Google ScholarGoogle Scholar
  17. H. G. Mairson. Deciding ML typability is complete for deterministic exponential time. In POPL, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. M. Odersky. Scaling DOT to Scala – soundness. http://scala-lang. org/blog/2016/02/17/scaling-dot-soundness.html, 2016.Google ScholarGoogle Scholar
  19. B. C. Pierce. Bounded quantification is undecidable. Information and Computation, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. A. Rossberg. Undecidability of OCaml type checking. Caml mailing list, 1999. http://caml.inria.fr/pub/old_caml_site/caml-list/1507.html. M. Sulzmann, G. J. Duck, S. L. P. Jones, and P. J. Stuckey. Understanding functional dependencies via constraint handling rules. J. Funct. Program., 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. R. Tate, A. Leung, and S. Lerner. Taming wildcards in Java’s type system. In PLDI, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. A. M. Turing. On computable numbers, with an application to the Entscheidungsproblem. J. of Math, 1936.Google ScholarGoogle Scholar
  23. T. L. Veldhuizen. C++ templates are Turing complete. Technical report, Indiana University, 2003.Google ScholarGoogle Scholar
  24. M. Viroli. On the recursive generation of parametric types. Technical report, University of Bologna, 2000.Google ScholarGoogle Scholar
  25. K. Wansbrough. Instance declarations are universal. http://www.lochan.org/keith/publications/undec.html (see also https://wiki.haskell.org/Type_SK), 1998.Google ScholarGoogle Scholar
  26. S. Wehr and P. Thiemann. On the decidability of subtyping with bounded existential types. In APLAS, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. S. Weirich. RepLib: a library for derivable type classes. In Haskell, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. J. B. Wells. Typability and type checking in System F are equivalent and undecidable. Annals of Pure and Applied Logic, 1999.Google ScholarGoogle ScholarCross RefCross Ref
  29. Y. Zhang, M. C. Loring, G. Salvaneschi, B. Liskov, and A. C. Myers. Lightweight, flexible object-oriented generics. In PLDI, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Java generics are turing complete

    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

    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!