Stephen Colebourne wrote:
The problem is erasure. The JDK wipes all knowledge of the type that you 
connect to the collection. Thus

List<String> list = new ArrayList();
if (list instanceof List<Integer>) {
}

fails to compile as the String type is erased.
In order to preserve backwards compatability, Sun had to go to extreme lengths 
to ensure that the erased type of each generics element corresponds to the 
previous type of the method. Consider the max method on Collections:

public static <T extends Object & Comparable<? super T>> T max(Collection<? 
extends T> coll)

Where because Object comes before Comparable in the list of bound types, its 
Object that the method signature gets erased to. Now thats pretty nasty.
Are fixes like this really grosser than a full package rename? Seems like the amount of code changed by fixing this in collections is much less than the amount of code changed if all the new users of collections need to change package names. Thus, the average upgrade experience would be better.
For [collections], there are cases worse than this, such as MultiMap, where the 
sf projects have demonstrated that it is not possible to generify the class 
without breaking backwards compatability, typically because our interface isn't 
a true implementation of the original interface.

If there are specific classes where you cannot fix them, it might make more sense to make parrallel classes rather than a whole package change. It seems like there will be more collections where creating generics is straightforward, than ones where it is impossible.
Beyond this, there are some classes (like TypedList that we don't even want to 
port as they'd be pointless), plus my desire to create a smaller jar file (time 
depending), there is ample reason to not worry excessively about backwards 
compatability. We shoud target about 90% backwards compatible, with the rest 
being fixing API flaws and issues we have now.

A simple port may appeal conceptually, but its not really viable at all.

Stephen





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to