Improving type error messages for generic Java

Nabil El Boustani, Jurriaan Hage*

*Corresponding author for this work

Research output: Contribution to journalArticlepeer-review

9 Citations (Scopus)


Since version 1.5, generics (parametric polymorphism) are part of the Java language. However, the combination of parametric polymorphism and inclusion polymorphism is complicated, particularly so for Generic Java. Indeed, the main Java compilers, Eclipse's ejc 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. Although the extension by itself already helps to improve type error messages to some extent, another major advantage of the new type inference process is that it also paves the way for further heuristics can provide additional diagnostic information. The extension has been implemented into the JastAdd Extensible Java Compiler.

Original languageEnglish
Pages (from-to)3-39
Number of pages37
JournalHigher-Order and Symbolic Computation
Issue number1-2
Publication statusPublished - Jun 2011


  • Compilers
  • Error diagnosis
  • Java generics
  • Type checking

ASJC Scopus subject areas

  • Software
  • Computer Science Applications


Dive into the research topics of 'Improving type error messages for generic Java'. Together they form a unique fingerprint.

Cite this