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.
- L. Damas and R. Milner. Principal type schemes for functional programs. In Principles of Programming Languages (POPL '82), pages 207--212, 1982. Google ScholarDigital Library
- T. Ekman and G. Hedin. JastAdd Extensible Java Compiler. http://jastadd.cs.lth.se/web/extjava. Google ScholarDigital Library
- N. el Boustani. Improving type error messages for generic java. http://www.cs.uu.nl/wiki/Hage/MasterStudents.Google Scholar
- J. Gosling, B. Joy, G. Steele, and G. Bracha. Java Language Specification. Addison-Wesley Professional, third edition, July 2005. Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- B. Heeren. Top Quality Type Error Messages. PhD thesis, Universiteit Utrecht, The Netherlands, 2005. http://www.cs.uu.nl/people/bastiaan/phdthesis.Google Scholar
- M. C. Jadud. A first look at novice compilation behaviour using BlueJ. Computer Science Education, 15(1):25--40, March 2005.Google ScholarCross Ref
- 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 Scholar
- R. Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 17:348--375, 1978.Google ScholarCross Ref
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
Index Terms
- Improving type error messages for generic java
Recommendations
Corrective hints for type incorrect generic Java programs
PEPM '10: Proceedings of the 2010 ACM SIGPLAN workshop on Partial evaluation and program manipulationSince version 1.5, generics (parametric polymorphism) are part of the Java language. Experience with implementations of the Java Language Specification such as EJC and JAVAC has shown that the type error messages provided by these tools leave more than ...
Improving type error messages for generic Java
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, ...
A type system for object initialization in the Java bytecode language
In the standard Java implementation, a Java language program is compiled to Java bytecode. This bytecode may be sent across the network to another site, where it is then executed by the Java Virtual Machine. Since bytecode may be written by hand, or ...
Comments