RFR: 8366584: Add an InstanceKlass::super() method that returns InstanceKlass* [v2]

Ioi Lam iklam at openjdk.org
Tue Sep 2 21:02:37 UTC 2025


On Tue, 2 Sep 2025 11:43:22 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> I think the term is "hides" not "shadows".  InstanceKlass::cast() is better - one additional check that super is always another InstanceKlass.
>
> Do we still need java_super ?

There are a few places that use it. Maybe we should look at these again in the future.


compiler dependencies:

./share/code/dependencies.cpp:      for (InstanceKlass* super = k->java_super(); super != nullptr; super = super->java_super()) {
./share/code/dependencies.cpp:      _klass = _klass->java_super();

subklass and sibling:

./share/oops/instanceKlass.cpp:    _current = _current->java_super(); // backtrack; no more sibling subclasses left
./share/oops/klass.cpp:  InstanceKlass* super = java_super();
./share/oops/klass.cpp:          && (super->java_super() == nullptr || !is_interface())),

Some general cases where you have a Klass but wants same super as in java.lang.Class::getSuperClass

./share/oops/klassVtable.cpp:  InstanceKlass* super = _klass->java_super();
./share/prims/jni.cpp:  // Rules of Class.getSuperClass as implemented by KLass::java_super:
./share/prims/jni.cpp:  Klass* super = k->java_super();
./share/prims/jni.cpp:         "java_super computation depends on interface, array, other super");
./share/services/heapDumper.cpp:  InstanceKlass* java_super = k->java_super();
./share/services/heapDumper.cpp:  assert(java_super != nullptr, "checking");
./share/services/heapDumper.cpp:  writer->write_classID(java_super);

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27037#discussion_r2317159260


More information about the hotspot-dev mailing list