RFR: 8364111: InstanceMirrorKlass iterators should handle CDS and hidden classes consistently [v3]

Aleksey Shipilev shade at openjdk.org
Tue Jul 29 08:30:56 UTC 2025


On Tue, 29 Jul 2025 06:54:01 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> I wondered briefly whether the allowance ("CLD = null is okay for newly-loaded classes") should be also made in
> 
> https://github.com/openjdk/jdk/blob/4669005123420d8dbe86740dd9bcbee04735bc4f/src/hotspot/share/memory/iterator.inline.hpp#L57-L59
> 
> But since we now handle mirror->referee Klass correctly in IMK, this only path affects oop->its Klass, and no instances exist yet for that Klass, right?

`ClaimMetadataVisitingOopIterateClosure::do_klass`  called from other places, not only IMK. So I believe those asserts could be reached through other means. What we handle here is only IMK.

> src/hotspot/share/oops/instanceMirrorKlass.inline.hpp line 126:
> 
>> 124: 
>> 125:   if (Devirtualizer::do_metadata(closure)) {
>> 126:     if (mr.contains(obj)) {
> 
> Unrelated, we could probably move mr.contains up to include `InstanceKlass::oop_oop_iterate_bounded<T>(obj, closure, mr);` to prevent the double check.

I am not sure about that, since `InstanceKlass::oop_oop_iterate_bounded` iterates the oop maps themselves, so the `mr.contains(obj)` likely filters too much. Anyway, since this is change in shared code, I would prefer to make the minimal possible thing to avoid accidentally breaking more stuff. So I am keeping this code as is.

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

PR Comment: https://git.openjdk.org/jdk/pull/26477#issuecomment-3131262981
PR Review Comment: https://git.openjdk.org/jdk/pull/26477#discussion_r2238961893


More information about the hotspot-dev mailing list