checkcast elimination
Deneau, Tom
tom.deneau at amd.com
Wed Jan 14 12:25:15 PST 2009
In the following method foo, an entry is being pulled from a Collection
class, in this case an ArrayList, and then being passed to another
method which takes an Object. The programmer stores the ArrayList
return in a myClass reference but never really uses it as a myClass
object. The javac compiler generates a "checkcast" bytecode and the
HotSpot JVM generates code for the checkcast.
Question: is it legal for the JVM to eliminate this cast check or is the
semantics of this code such that the JVM is required to generate an
exception if the cast fails (even though the reference is never really
used as a myClass) ?
-- Tom
=================
ArrayList<myClass> aList;
void foo(int i) {
myClass myc = aList.get(i);
bar(myc);
}
void bar(Object x) {
...
}
More information about the hotspot-dev
mailing list