1. Java 2 Platform Standard Edition (J2SE) 5.0 ("Tiger") is the next major revision to the Java platform and language; it is
currently slated to contain 15 component JSRs with nearly 100 other significant updates developed through the Java
Community Process (JCP).
NOTE: The external version number of this release is 5.0 and its internal version number is 1.5.0, as described at J2SE
Naming and Versioning.
• Generics - This long-awaited enhancement to the type system allows a type or method to operate on objects of
various types while providing compile-time type safety. It adds compile-time type safety to the Collections
Framework and eliminates the drudgery of casting. See the Generics Tutorial. (JSR 14)
• Enhanced for Loop - This new language construct eliminates the drudgery and error-proneness of iterators and
index variables when iterating over collections and arrays. (JSR 201)
• Autoboxing/Unboxing - This facility eliminates the drudgery of manual conversion between primitive types (such
as int) and wrapper types (such as Integer). (JSR 201)
• Typesafe Enums - This flexible object-oriented enumerated type facility allows you to create enumerated types
with arbitrary methods and fields. It provides all the benefits of the Typesafe Enum pattern ("Effective Java,"
Item 21) without the verbosity and the error-proneness. (JSR 201)
• Varargs - This facility eliminates the need for manually boxing up argument lists into an array when invoking
methods that accept variable-length argument lists.
• Static Import - This facility lets you avoid qualifying static members with class names without the shortcomings of
the "Constant Interface antipattern." (JSR 201)
• Annotations (Metadata) - This language feature lets you avoid writing boilerplate code under many
circumstances by enabling tools to generate it from annotations in the source code. This leads to a "declarative"
programming style where the programmer says what should be done and tools emit the code to do it. Also it
eliminates the need for maintaining "side files" that must be kept up to date with changes in source files. Instead
the information can be maintained in the source file. (JSR 175)
NOTE: The @Deprecated annotation provides a way to deprecate program elements. See How and When To
Deprecate APIs.
Metadata
The metadata feature in J2SE 5.0 provides the ability to associate additional data alongside Java classes, interfaces,
methods, and fields. This additional data, or annotation, can be read by the javac compiler or other tools, and depending
on configuration can also be stored in the class file and can be discovered at runtime using the Java reflection API.
One of the primary reasons for adding metadata to the Java platform is to enable development and runtime tools to have
a common infrastructure and so reduce the effort required for programming and deployment. A tool could use the
metadata information to generate additional source code, or to provide additional information when debugging.
In beta2 we are pleased to announce the availability of an annotation processing tool called apt. Apt includes a set of
new reflective APIs and supporting infrastructure to process program annotations. The apt reflective APIs provide a build-
time, source-based, read-only view of program structure which cleanly models the Java programming language's type
system. First, apt runs annotation processors that can produce new source code and other files. Next, apt can cause
compilation of both original and generated source files, easing development. For more information on apt refer to
the apt guide.
In the following example code you can additionally create an AnnotationFactory processor for apt to generate code or
documentation when finding the debug annotation tag.
import java.lang.annotation.*;
import java.lang.reflect.*;
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @interface debug {
boolean devbuild() default false;
int counter();
}
public class MetaTest {
final boolean production=true;
@debug(devbuild=production,counter=1) public void testMethod() {
}
public static void main(String[] args) {