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

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


On Tue, 2 Sep 2025 04:56:50 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Ioi Lam has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Added assert in heapInspection.cpp
>
> src/hotspot/share/memory/heapInspection.cpp line 405:
> 
>> 403:                                                       bool print_subclasses) {
>> 404:   // Set do_print for all superclasses of this class.
>> 405:   InstanceKlass* super = InstanceKlass::cast(cie->klass())->super();
> 
> Pre-existing, but if this cast is safe then `KlassInfoEntry::_klass` should be declared `InstanceKlass`. Otherwise this cast is not safe! Separate RFE for that.

I looked at the `KlassHierarchy` code and it looks at only instance klasses.

https://github.com/openjdk/jdk/blob/80fb7088a10136080d23ea93b4840f17d738500c/src/hotspot/share/memory/heapInspection.cpp#L318-L319

I added an assert to make this more apparent.

The `KlassInfoEntry` is used by other code that could sometimes store a non-instance klass. I'll leave it as is for now.

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

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


More information about the serviceability-dev mailing list