When APIs are generified using concrete instantiations of generic types, but
clients continue to use (now redundenat) casts in their code, javac elides
both the automatically-generated cast and the redudnant one, resulting in
unverifiable code.
here is a simplified test case:
import java.util.*;
class Z2 {
protected Vector<String> v = null;
public void f() {
((String) (v.elementAt(0))).charAt(0);
}
public static void main(String[] args) {}
}
clients continue to use (now redundenat) casts in their code, javac elides
both the automatically-generated cast and the redudnant one, resulting in
unverifiable code.
here is a simplified test case:
import java.util.*;
class Z2 {
protected Vector<String> v = null;
public void f() {
((String) (v.elementAt(0))).charAt(0);
}
public static void main(String[] args) {}
}
- duplicates
-
JDK-5036084 Javac generates corrupt bytecode if redundant cast included in source.
- Closed
-
JDK-5042634 A runtime error when casting is used with generics and brackets
- Closed