Java News from Friday, November 21, 2003

Sun's Joshua Bloch has posted the public review draft specification Java Specification Request (JSR) 175 A Metadata Facility for the Java Programming Language to the Java Community Process. According to the draft,

This document describes a simple program annotation facility for the Java programming language. This facility allows developers to define custom annotation types and to annotate fields, methods, classes, and other program elements with annotations corresponding to these types. These annotations do not directly affect the semantics of a program. Development and deployment tools can, however, read these annotations and process them in some fashion, perhaps producing additional Java programming language source files, XML documents, or other artifacts to be used in conjunction with the program containing the annotations. For example, a tool called a stub generator could generate remote procedure call stubs as directed by annotations indicating which methods were designed for remote use.

Think of this as JavaDoc won steroids. An example from the spec follows:

// Normal annotation type declaration with several members

 * Describes the "request-for-enhancement" (RFE) that led to the presence of 
 * the annotated API element.
public @interface RequestForEnhancement {
    int    id();        // Unique ID number associated with RFE
    String synopsis();  // Synopsis of RFE
    String engineer();  // Name of engineer who implemented RFE
    String date();      // Date RFE was implemented

On a very positive note, the specification is published in HTML rather than PDF like most Sun specs. Now if we could just convince Sun to make it available on the Web instead of forcing users to download a zip file. (And just to head of a frequent comment, this would in no way prevent Sun from enforcing license agreement as they do now. A document such as this can easily be a response to a POST request. Whether you should have to accept the license to read the document is another story, but there's not technical problem with it.) Comments are due by December 5.