Friday, June 15, 2007

JSR 3000: Annotation Closures

(Inspired by a post by Weiqi Gao and Wired magazine's Artifacts from the Future).

CtJ Newswire
Parody City, CA
June 2010

Several industry leaders announced today that they will support JSR 3000, an initiative to add closures to the JML (Java Metadata Language). The effort ends much debate among heavyweights in the Java community,which began with the hotly-contested JSR 1969 and bitterly-disputed JSR 2001, which added control structures and objects, respectively, to the JML.

Said one industry leader, "Not only has the JML become a full Turing machine with OO capabilities, but now with annotated closures, we should see entire web frameworks in a single class file. The amount of true Java code will be miniscule, and javac and apt will do most of the work. Once we solve the problem of distributing javac and apt to customers, we will have truly arrived in a new age".

The press announcement offered the following as an example of the new syntax. The JCP website was briefly shutdown due to overwhelming volume.


// print lines of file
@MyFileTraverser extends Object
@Field("file", private)
@Field("myClosure", private)
@Method("traverse", public)
@Invoke("myClosure", "file")
@
@If.exists(args[0])
@New("myTraverser", MyFileTraverser)
@Set("file", args[0])
@Set("myClosure",
@{ String line => System.out.println(line)} )
@Invoke("myTraverser", "traverse")
@Else
@Exit("usage: please pass a file name to apt")
public class HelloWorld {
static public void main(String args) {
System.err.println(
"error: raw JVM bytecode reached.");
System.err.println(
"error: please contact system admin");
}
}

No comments: