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

David Holmes dholmes at openjdk.org
Tue Sep 2 07:10:43 UTC 2025


On Tue, 2 Sep 2025 04:59:37 GMT, David Holmes <dholmes at 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 921:
> 
>> 919:   }
>> 920: 
>> 921:   // This shadows Klass::super(). The _super of an InstanceKlass is
> 
> Suggestion:
> 
>   // This overrides Klass::super(). The _super of an InstanceKlass is

Correction: this is not "overriding" as defined by C++. "shadow" is fine.

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

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


More information about the hotspot-dev mailing list