On Extending Java

Andreas Krall and Jan Vitek

Institut für Computersprachen
Technische Universität Wien
Argentinierstraße 8
A-1040 Wien, Austria
andi@complang.tuwien.ac.at

and

Object Systems Group
Centre Universitaire d'Informatique
Université de Genève
24, rue Général-Dufour
CH-1211 Genève 4, SWITZERLAND
jvitek@cui.unige.ch

Abstract

The design of Java sports a simple and elegant object model. Its simplicity may well be the language's main selling point - it is both easy to learn and to implement - but in the long run the same simplicity may prove to be a sign of a lack of expressive power that could hinder the development of large software systems. We present four non-intrusive language extensions, tuples, closures, anonymous objects and iterators, give examples of use and detail a translation scheme into plain Java. These extensions enhance the expressive power of Java and allow certain common programming idioms to be coded more naturally.