I've read Neal Gafter's blog on the subject and am still unclear on a number of points.
Why is it not possible to create implementations of the Collections API that preserve type information given the current state of Java, the JVM and existing collections API? Couldn't these replace the existing implementations in a future version of Java in a way where backwards compatibility is preserved?
As an example:
List<T> list = REIList<T>(T.Class);
Where REIList is something like this:
public REIList<T>() implements List {
private Object o;
private Class klass;
public REIList(Object o) {
this.o = o;
klass = o.getClass();
}
... the rest of the list implementation ...
And the methods use Object o and Class klass to get the type information.
Why would preserving generic class information require language changes rather than just a JVM implementation change?
What am I not understanding?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…