New additions to the Java language

By: David Intersimone

Abstract: In a keynote at Java One 2001 in San Francisco, James Gosling gave a roadmap for the Java language.

New additions to the Java language

It's been awhile since new syntax was added to the Java language. Up until now, Sun Microsystems has preferred to keep the language stable, focus on adding APIs, and using the Java Community Process (JCP) to drive new language feature discussions and decisions. So what new features will be added to the Java language in the next year or so? In a keynote at Java One 2001 in San Francisco, James Gosling gave a roadmap for the Java language.

In his keynote, James Gosling, said that the "goal has been to keep the language and the underpinnings of Java stable." He discussed to major new additions to the Java language:

Gosling said that these two features have been "the top two on the feature list" for some time.

Assertions - JSR014

Gosling said that assertions were in the Java language spec version 0.9, but were removed because "it was half-baked and I was not happy with it". Through the Java community process the discussion was started which has lead to the addition of the feature to the language. He said that, "after all the discussion, the community converged on a simple design." There are two forms of assertion statements:

assert expression1;assert(i > arr.length);
assert expression1 : expression2;assert(result != null : "Missing Result");

If expression1's result is not a boolean type, a compiler error will occur. You can include assertion code with your applications. Developers also have the option to use conditional compilation to strip out assertions. Support for Assertions will be available in JDK 1.4.

You'll find the JDK 1.4 Assertion language document is at

A Beta of JDK 1.4 is available for download at

Generics - JSR014

Gosling said that generics (aka templates, type polymorphism) had been requested for more years that Java has been out. "It is the #1 requested Java feature". He said that generics have been the source of heated debate for years. Gosling said that [the discussion about] "generics is the thing that caused Bill Joy and I to get as close to physical violence as we've ever gotten." He felt that developers could get by using the class hierarchy. In fact, early container libraries, implemented in Java, have used the base object class and returned objects. Gosling protrayed the early discussion as a "food fight" with great input from all over the world. He said that "about two years ago, people converged on an answer". Just about then the Java Community Process started, and the effort was moved over to a JCP group to finish the work.

In his presentation, Gosling showed an example snippet of code for Generics in Java. The example used hashing to map strings to employee records.

  // map strings to employees
  Map employees = new HashMap;
  Employees e = ...;
  employees.put(, e);
  employees.put(e,; // error!
  e = employees.get("Harry Bovik"); // no cast required

The public specification for generics says that two new forms of types are being added: parameterized types and type variables. A parameterized type includes a class or interface and a parameter section containing a list of types. A type variable is an unqualified identifier.

Gosling mentioned that the public review period closes in August. He told everyone to "speak now or forever hold your peace". Generics are scheduled to be added to the language in JDK 1.5.

There is a prototype implementation available from Sun at The JDK includes specs, a compiler, and source for the compiler.

There is also a public review draft specification at

Server Response from: ETNASC03