EVALUATION
Actually, there is no compiler magic in getSuperclass() that would lead to a
type loophole. If you try the example in the description you'll see why.
However, there IS a problem due to the interaction of getClass() and
cast(), and due to the interaction of class literals of generic types and
cast(). We can fix these by requiring that all values of type Class<>
generated by these techniques erase the argument type. A spec based on this
scheme is awaiting CCC approval.
###@###.### 2004-02-27
Here's the real type loophole in action:
List<String> ls = new ArrayList<String>();
List<Integer> li = new ArrayList<Integer>();
li = li.getClass().cast(ls); // no unchecked assignment warning
li.add(1);
String s = ls.get(0); // BANG!
###@###.### 2004-04-02
Parameterized class literals are already disallowed by the grammar.
We should also disallow parameterized types from being used in
instanceof expressions, since there's nothing that can be done with
the type arguments at run time.
###@###.### 2004-04-02
|