Genja - A New Proposal for Parameterised Types in Java Mark Evered, James Leslie Keedy, Gisela Menger, Axel Schmolitzky University of Ulm Abteilung Rechnerstrukturen Universität Ulm 89069 Ulm Germany markev@informatik.uni-ulm.de Abstract: Recent proposals for adding parameterised types to Java have left a number of important practical issues undiscussed. In this paper we present the language Genja which is a new generic extension of Java oriented towards practical support for generic collection types. We discuss design alternatives related to extending the power of unconstrained genericity, solving the weaknesses of constrained genericity in other proposals and defining the compatibility of named and anonymous instantiations. By enhancing support for reusability and providing a higher level style of programming via a library of standard generic collection types Genja aims to extend Java's contribution to efficient software production. 1 Introduction It is well recognised that the addition of parameterised types to Java [Gosling 96] could significantly enhance its support for software reuse. Current Java programming practice (as seen for example in the library classes 'Vector' and 'HashTable') is to make use of the root class 'Object' and run-time type checks as an alternative to parameterised types but this involves a run-time overhead and discovers errors later than desirable. Two proposals have recently been made for parameterised types in Java. (A third proposal [Thorup 97] is not discussed here since it assumes dynamic type checks and we are concerned with static type safety.) The proposal by the MIT group [Myers 97] is based on the mechanism of the language Theta [Liskov 95]. The second proposal is contained in the language Pizza [Odersky 97] which is an extension of Java including not only parameterised types but also first-class functions and algebraic types. We feel that a number of alternatives and important practical issues have remained undiscussed in all of these proposals. These include: the main uses for parameterised types and good practical support for these uses a discussion of the possible parameters of types primitive types as type parameters conformity with the general style of Java possible alternatives for the instantiation and naming of parameterised types compatibility of instantiated parameterised types appropriate extensions to the Java standard packages In particular, the first point has a major influence on decisions concerning the others. Examples of parameterised types are almost invariably collection types of some kind such as sets, lists and stacks with the type of the elements being the parameter to the parameterised type. It seems clear that abstract or concrete collection types are by far the most common use for type parameterisation. This can be seen, for example, in the standard Eiffel class library [Meyer 94] and in the Standard Template Library [Musser 96] for C++. Collections of data are one of the most important aspects of software development. The consistent use of standard generic collection types can greatly reduce development costs and