skip to main content
10.1145/1480945.1480964acmconferencesArticle/Chapter ViewAbstractPublication PagespepmConference Proceedingsconference-collections
research-article

Improving type error messages for generic java

Published:19 January 2009Publication History

ABSTRACT

Since version 1.5, generics (parametric polymorphism) are part of the Java language. However, adding parametric polymorphism to a language that is built on inclusion polymorphism can be confusing to a novice programmer, because the typing rules are suddenly different and, in the case of Generic Java, quite complex. Indeed, the main Java compilers, Eclipse's EJC compiler and Sun's JAVAC, do not even accept the same set of programs. Moreover, experience with these compilers shows that the error messages provided by them leave more than a little to be desired. To alleviate the latter problem, we describe how to adapt the type inference process of Java to obtain better error diagnostics for generic method invocations. The extension has been implemented into the JastAdd extensible Java compiler.

References

  1. L. Damas and R. Milner. Principal type schemes for functional programs. In Principles of Programming Languages (POPL '82), pages 207--212, 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. T. Ekman and G. Hedin. JastAdd Extensible Java Compiler. http://jastadd.cs.lth.se/web/extjava. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. N. el Boustani. Improving type error messages for generic java. http://www.cs.uu.nl/wiki/Hage/MasterStudents.Google ScholarGoogle Scholar
  4. J. Gosling, B. Joy, G. Steele, and G. Bracha. Java Language Specification. Addison-Wesley Professional, third edition, July 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. J. Hage and B. Heeren. Heuristics for type error discovery and recovery. In Z. Horváth, V. Zsók, and A. Butterfield, editors, Implementation of Functional Languages -- IFL 2006, volume 4449, pages 199--216, Heidelberg, 2007. Springer Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. G. Hedin and E. Magnusson. The JastAdd system -- an aspect-oriented compiler construction system. Science of Computer Programming, 47(1):37--58, April 2003. http://www.cs.lth.se/gorel/publications/2003-JastAdd-SCP-Preprint.pdf. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. B. Heeren. Top Quality Type Error Messages. PhD thesis, Universiteit Utrecht, The Netherlands, 2005. http://www.cs.uu.nl/people/bastiaan/phdthesis.Google ScholarGoogle Scholar
  8. M. C. Jadud. A first look at novice compilation behaviour using BlueJ. Computer Science Education, 15(1):25--40, March 2005.Google ScholarGoogle ScholarCross RefCross Ref
  9. O. Lee and K. Yi. A generalization of hybrid let-polymorphic type inference algorithms. In Proceedings of the First Asian Workshop on Programming Languages and Systems, pages 79--88, National university of Singapore, Singapore, December 2000.Google ScholarGoogle Scholar
  10. R. Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17:348--375, 1978.Google ScholarGoogle ScholarCross RefCross Ref
  11. D. Smith and R. Cartwright. Java type inference is broken: Can we fix it? In Proceedings of the 23rd Conference on Object-oriented programming, systems, languages, and applications (OOPSLA '08), pages 505--524, New York, NY, USA, 2008. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. M. Torgersen, C. Plesner Hansen, E. Ernst, P. von der Ahé, G. Bracha, and N. Gafter. Adding wildcards to the Java programming language. In Proceedings of the 2004 ACM Symposium on Applied Computing (SAC '04), pages 1289--1296, New York, NY, USA, 2004. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. J. Yang. Explaining type errors by finding the sources of type conflicts. In Greg Michaelson, Phil Trinder, and Hans--Wolfgang Loidl, editors, Trends in Functional Programming, pages 58--66. Intellect Books, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Improving type error messages for generic java

    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
    • Published in

      cover image ACM Conferences
      PEPM '09: Proceedings of the 2009 ACM SIGPLAN workshop on Partial evaluation and program manipulation
      January 2009
      208 pages
      ISBN:9781605583273
      DOI:10.1145/1480945

      Copyright © 2009 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 19 January 2009

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate66of120submissions,55%

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader