On Tue, 2 Sep 2025 04:59:09 GMT, David Holmes <dhol...@openjdk.org> wrote:
>> By adding an `InstanceKlass* InstanceKlass::super()` method to shadow >> `Klass* Klass:super()`, this PR makes it possible to simplify the following >> code >> >> >> InstanceKlass* ik; >> InstanceKlass* s; >> s = InstanceKlass::cast(ik->super()); // before JDK-8366024 >> s = ik->java_super(); // after JDK-8366024 >> >> >> to >> >> >> s = k->super(); >> >> >> So you no longer need to do casting or need to understand what >> `java_super()` is. > > src/hotspot/share/oops/instanceKlass.hpp line 924: > >> 922: // always an InstanceKlass (or nullptr) >> 923: InstanceKlass* super() const { >> 924: return (Klass::super() == nullptr) ? nullptr : >> InstanceKlass::cast(Klass::super()); > > Is it better/simpler/cleaner to just do: > > return static_cast<InstanceKlass*>(Klass::super()); > > ? I think the term is "hides" not "shadows". InstanceKlass::cast() is better - one additional check that super is always another InstanceKlass. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/27037#discussion_r2315826675