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 2009 Publication 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.
[2]
T. Ekman and G. Hedin. JastAdd Extensible Java Compiler. http://jastadd.cs.lth.se/web/extjava.
[3]
N. el Boustani. Improving type error messages for generic java. http://www.cs.uu.nl/wiki/Hage/MasterStudents.
[4]
J. Gosling, B. Joy, G. Steele, and G. Bracha. Java Language Specification. Addison-Wesley Professional, third edition, July 2005.
[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.
[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.
[7]
B. Heeren. Top Quality Type Error Messages. PhD thesis, Universiteit Utrecht, The Netherlands, 2005. http://www.cs.uu.nl/people/bastiaan/phdthesis.
[8]
M. C. Jadud. A first look at novice compilation behaviour using BlueJ. Computer Science Education, 15(1):25--40, March 2005.
[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.
[10]
R. Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17:348--375, 1978.
[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.
[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.
[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.

Cited By

View all

Index Terms

  1. Improving type error messages for generic java

    Recommendations

    Comments

    Information & Contributors

    Information

    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
    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]

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 19 January 2009

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. compilers
    2. error reporting
    3. java generics
    4. type checking

    Qualifiers

    • Research-article

    Conference

    PEPM '09
    Sponsor:
    PEPM '09: Partial Evaluation and Program Manipulation
    January 19 - 20, 2009
    GA, Savannah, USA

    Acceptance Rates

    Overall Acceptance Rate 66 of 120 submissions, 55%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)5
    • Downloads (Last 6 weeks)0
    Reflects downloads up to 18 Feb 2025

    Other Metrics

    Citations

    Cited By

    View all
    • (2019)Apla Generic Constraint Matching Detection and Verification2019 24th International Conference on Engineering of Complex Computer Systems (ICECCS)10.1109/ICECCS.2019.00030(210-219)Online publication date: Nov-2019
    • (2017)SkalpelJournal of Symbolic Computation10.1016/j.jsc.2016.07.01380:P1(164-208)Online publication date: 1-May-2017
    • (2010)On compiler error messagesAdvances in Human-Computer Interaction10.1155/2010/6025702010(1-26)Online publication date: 1-Jan-2010
    • (2010)What would other programmers doProceedings of the SIGCHI Conference on Human Factors in Computing Systems10.1145/1753326.1753478(1019-1028)Online publication date: 10-Apr-2010
    • (2010)Corrective hints for type incorrect generic Java programsProceedings of the 2010 ACM SIGPLAN workshop on Partial evaluation and program manipulation10.1145/1706356.1706360(5-14)Online publication date: 19-Jan-2010

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Figures

    Tables

    Media

    Share

    Share

    Share this Publication link

    Share on social media