C. Scott Ananian
I've been playing with the various prototype compilers that Sun has been releasing as part of its "Extending the Java Programming Language with Generic Types" project (JSR-14). I've been programming with JSR-14 for about two years now, since the early 1.0 prototypes. In July Sun released version 2.2 of the prototype compiler, with support for wildcards (née variance) and JSR-201 (enumerations, autoboxing, for loop enhancements, and import of static members). A new syntax for varargs has also been included.
This page is a place to collect my various work on GJ-related things, including:
The current prototypes are *almost* but still-not-quite able to compile FLEX; I'll probably keep hacking on things until the GJ compiler is bug-free and usable enough to let me get Real Work Done on FLEX.
It's worth noting that, in addition to JSR-14 and JSR-201, also proposed for Java 1.5 are JSR-133 (revisions to the java memory model and threads) and JSR-181 (a metadata facility). There is also an official page for VGJ, the variance-enabled compiler.
I (and others) have also written a
package of parameterized
collections classes which greatly extend the power of the
standard java.util
library. This library
was originally developed for the FLEX project.
Release 2.2 was July 23, 2003. J2SE 1.5 Beta 1, with JSR-14 and JSR-201, may be in November or early next year. Neal Gafter has hinted at another prototype in October.
Also, according to Neal:
The next prototype will include copies of the rough draft specs for JSRs 14 175 201 and 202.
Full JSR-175 metadata support will likely not be available until the J2SE 1.5 Beta, although specs and compiler support for writing metadata attributes is likely in the next prototype.
This is still in active development. You can download the current version 0.5 sources; caveat emptor. API documentation (no frames version) generated by the tool is also available, as is a list of changes made since the last release. Version 0.5 of SinjDoc parses all of the syntax understood by prototype 2.4a1 of the JSR-14 compiler, including wildcards and JSR-201 constructions. It should even handle arrays of wildcard types which seem to be supported in the latest prototype compiler. JSR-175 annotations are not yet supported.
Sign up on the SinjDoc-Announce mailing list to be notified of new releases of SinjDoc.
Subscribe to SinjDoc Announce List |
Visit this group |
For a good example of what this tool can do, look at the generated documentation for the FLEX compiler infrastructure, which is generated using it.
Archive of previous releases: [0.1] [0.2] [0.3] [0.4] [0.5]
I've written a no-frills javap
-like tool that a) doesn't
choke on bytecode emitted by the JSR-14 compiler, as does the standard
Sun javap
, and b) actually parses the JSR-14
Signature
attribute to emit the correct parameterized signature
for the methods in the class. This was invaluable to be in
looking through the jar
files supplied with the
prototype compilers to look for what had changed. Maybe it will be
helpful to you, too. I've updated it to support the
new signature format
(and Java syntax) of the 2.4 prototype.
To use:
Harpoon.jar
which
contains the code for the tool. This is actually a full
FLEX distribution,
which is why the download is rather porky.% java -cp Harpoon.jar harpoon.Main.Javap java.util.AbstractSet(with the class you are interested in replacing
java.util.AbstractSet
, of course.)collect.jar
file
is also on your classpath, or you're likely to get the (mostly
uninteresting) prototypes of the pre-GJ Collections classes; if
the output of the command above doesn't give you GJ types on
AbstractSet
, this is the most likely reason why.
The prototype compilers have changed the "generic"-ified Collections (and
other?) APIs, but do not come with updated javadoc. As a result,
your existing code which extends Collections tends to mysteriously
fail because your type signatures no longer match properly. (It
didn't help that the prototype compiler used to crash hard for some of
these mismatches.) So --- to ease your pain, I've generated
new javadoc for you with the help of my sinjdoc
tool.
This is accurate to what is shipping with the 2.2 prototype;
the bugs list below will note areas (if any) where
I think this API should change, or where I've been told that the API
will change.
Javadoc for generified parts of the Java standard libraries. [frames] [no frames]
Old bug list for 2.0 prototype compiler.
Old bug list for 1.3 prototype compiler.
Old bug list for 1.2 prototype compiler.
Here are the bugs I know about or suspect are in the 2.2 prototype compiler. Note that these may or may not have been confirmed by the good folk at Sun, so some of these might actually be "features" in disguise.
Items in red are those I consider "showstoppers". I've been very conservative marking things showstoppers, not marking them if there seems to be a manageable workaround, the bug might be construed as simply a "missing feature", or there is any doubt as to whether the bug will be relevant for the "final" JSR-14 spec. Your opinions as to seriousness may well vary from mine.
javac
scripts
don't work on Mac OS X. The linked thread in the GJ forum
contains a patch to work around this.
enum
details to watch out for:
enum
types are implicitly static.
Class.getMethod()
in the presence
of bridge methods is uncertain, surprising, or incorrect.
return
statement does not seem to be
treated as an assignment conversion, as it ought to be
(found by "veenurs" in the GJ forum).
You will also not be able to use autoboxing
in a foreach loop.
Finally,
autoboxing does not interoperate with inference in the expected manner.