We are calling InstanceKlass::cast(k) in many places where k is statically known to be an InstanceKlass. We probably have very old code that used "Klass* Klass::super()" before "InstanceKlass* InstanceKlass::java_super()" was introduced, or code written by people who didn't know the difference between "super()" and "java_super()".
Example
https://github.com/openjdk/jdk/blob/603526b55b5e9b6dfc9323d2cdc4a0b4d0f88a49/src/hotspot/share/oops/instanceKlass.cpp#L1855-L1857
{ Klass* supr = super();
if (supr != nullptr) return InstanceKlass::cast(supr)->find_field(name, sig, is_static, fd);
}
It should be rewritten to
{ InstanceKlass* supr = java_super();
if (supr != nullptr) return supr->find_field(name, sig, fd);
}
Example
https://github.com/openjdk/jdk/blob/603526b55b5e9b6dfc9323d2cdc4a0b4d0f88a49/src/hotspot/share/oops/instanceKlass.cpp#L1855-L1857
{ Klass* supr = super();
if (supr != nullptr) return InstanceKlass::cast(supr)->find_field(name, sig, is_static, fd);
}
It should be rewritten to
{ InstanceKlass* supr = java_super();
if (supr != nullptr) return supr->find_field(name, sig, fd);
}
- links to
-
Review(master) openjdk/jdk/26908