January 24, 2004

Big Changes in Java 1.5 Alpha

Java 1.5 introduces major new changes to the language.
And there is now an alpha release so you can try them out.

The alpha release doesn't include documentation, but the JSRs that define the language features are in public review at the JCP, which means that you can learn about (and coment on, if you choose) these new features.

First up is JSR 14 which adds parameterized types to the language. This is huge. You can use types like:

Map<String,Integer> map = new HashMap<String,Integer>

The public review draft for this is really old, and slighly out of sync with reality. There ought to be a new version soon.

Next is JSR 201, a catch-all for five smaller, but no less exciting, language changes. They are:

  • enumerated constants
  • a new for() loop for easily iterating through the elements of collections and arrays. Basically a foreach loop, but it isn't called that
  • autoboxing and unboxing: primitive values are "boxed" into wrapper objects as needed, and wrapper objects are unboxed into primitive values as needed.
  • varargs -- methods can have variable numbers of arguments (as long as the variable part of the argument list are all of the same type)
  • the ability to import the static members of a class, such as the constants defined by an enumerated type or the methods of the java.lang.Math class.

I served on the expert group for this JSR. Public review has just begun, so read the public review draft, and let us know if you find problems.

Finally, JSR 175 adds metadata or annotations to the language. This is a cool, but fairly obscure feature. I believe it is of primary interest to J2EE types who want to be able to add things like deployment information directly to classfiles. I also get the impression that this feature is being added to Java now because C# has it. The public review comment period for this JSR has closed, but you can still read the public review draft to learn about it.

| TrackBack
Comments