JDK-4345822 : Generic Java compiler enhancement for reliability and readability
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 1.2.2,1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2000-06-15
  • Updated: 2001-11-07
  • Resolved: 2001-11-07
Related Reports
Duplicate :  
Duplicate :  
Description

Name: stC104175			Date: 06/15/2000


java version "1.2.2"
Classic VM (build JDK-1.2.2-001, native threads, symcjit)

If this is not the right place to request this feature enhancement, please
direct me to the correct place.

Generic Java

At the Colorado Software Summit last year, Bill Joy said that some sort of
generic or tempate-like mechanism needed to be added to Java.  But at Java One
this year, at the Generic Java BOF, I found out that there did not seem to any
plans to add this feature any time soon because no one was asking for it!  So
I'm asking for it, for two reasons:

1. Bill Joy said that the basic value proposition of Java is that the language
has meaning, so that things can be proved about it.  In my view, the lack of a
Generic capability reduces the meaning of the language.  For example, if I have
an ArrayList containing five Widgets, the Java language without generics acts as
if I have an ArrayList containing five Objects.  Generic Java retains the
information that the ArrayList contains Widgets and this increases the meaning
and therefore the reliability of the language.  In my view, you have to justify
not including Generic Java in the Java langauge because excluding it goes
against the basic value proposition of Java.

2. In my experience, the lack of generic containers significant decreases the
readability of Java.  For example, we have a data structure in our system that
uses a HashMap containing ArrayLists containing various types of data.  Code
reviews on the code using this data structure are extremely difficult because so
much of the type information is lost when things are put in containers.  Every
time there is another reference to an ArrayList, we have to figure out which
ArrayList it is and what data it is supposed to contain and then verify that
everything put in it has the right type and every cast on the data coming out of
it is correct.  The compiler can't help with this at all because all the type
information is lost.  Generics would make the code much more readable because
the type of the contents would not be lost, but would be preserved in every
reference to the type.
(Review ID: 106199) 
======================================================================

Comments
WORK AROUND Name: stC104175 Date: 06/15/2000 The Generic Java (GJ) compiler is available, but since generics are not part of the language, using this compiler would prevent us from using any other compiler or integrated development environment. ======================================================================
11-06-2004