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. In addition, I've hung around the Forum trying to remedy some deficiencies in the prototypes released so far.
This page is a place to collect my various work on GJ-related things, including updated javadoc for the current 1.2 prototype compiler, a javap tool that works on GJ class files, and a a list of bugs I've found in the 1.2 prototype. I'm working on converting FLEX to GJ, so I'll probably keep hacking on things until the GJ compiler is bug-free enough to let me get Real Work Done on FLEX.
The 1.2 prototype compiler updated the GJ-ified Collections (and
other?) APIs, but did 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
doesn't help that the prototype compiler crashes hard for some of
these mismatches. So --- to each your pain, I've gone through
the javadoc with the help of my javap
-like tool
below and manually tried to fixup the javadoc to be accurate.
Note that this is accurate to what's shipping now with the 1.2
prototype; note my list below for details on
what I think may be "broken"
in this release and thus slated for change in future releases.
So, without further ado, here are some links to the goodies:
I've written a no-frills javap
-like tool that a) doesn't
choke on bytecode emitted by the GJ compiler, as does the standard
Sun javap
, and b) actually parses the GJ
Signature
attribute to emit the correct GJ signature
for the methods in the class. This was invaluable to be in
looking through the jar
files supplied with the
1.2 compiler to look for what had changed. Maybe it will be
helpful to you, too.
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.
Here are the bugs I know about or suspect are in the 1.2 prototype compiler. Note that none of these have been confirmed by the good folk at Sun yet, so some of these might actually be "features" in disguise.
java.util.Arrays
/java.util.Collections
(questionable)java.util.Arrays
javadoc had the signatures:public static <T extends Comparable<T>> int binarySearch(T[] a, T key); public static <T extends Comparable<T>> void sort(T[] a);But their signatures in the classfile have always been (in 1.0 and 1.2 prototypes):
public static <T> int binarySearch(T[] a, T key); public static <T> void sort(T[] a);
My "bug-fixed" javadoc lists
signatures that match the class file (i.e. without the
Comparable
bounds), and I'm guessing this is the "correct"
signature due to array oddities --- the array could have nothing but
Comparable
objects in it, but the array type
could safely be something bland like Object[]
; thus the
Comparable
bound is too strict.
One of the java.util.Collections.sort()
methods has
the same issue.
java.util.Collections
Collections.unmodifiableCollection()
method has the
signature:public static <T> java.util.Collection unmodifiableCollection(java.util.Collection<T>);The signature should be:
public static <T> java.util.Collection<T> unmodifiableCollection(java.util.Collection<T>);
java.util.HashMap
HashMap
constructor has been overlooked. Its signature is:HashMap(Map<K,V> t);By analogy to the
ArrayList
, HashSet
, and
Hashtable
constructors, this signature should be:<A extends K, B extends V> HashMap(Map<A,B> t);
Signature
attributes in the
classfiles. You probably won't notice this, since nothing really uses
these at the moment, except javap
-like tools and the new
GJ reflection capabilities (which I don't think are implemented in any
available code yet). But I'm pretty sure this is a bug, and here are the details.
addAll()
, putAll()
, etc.
Details in the link.