RFR: 8364111: InstanceMirrorKlass iterators should handle CDS and hidden classes consistently
Aleksey Shipilev
shade at openjdk.org
Fri Jul 25 17:04:58 UTC 2025
On Fri, 25 Jul 2025 16:56:48 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
>> Good point. We create the mirror then initialize the class, so a concurrent GC could see a null Klass pointer.
>
> Actually, I now see this assert is tautological: `java_lang_Class::is_primitive` checks that `java_class->metadata_field(_klass_offset) == nullptr`, which is the same as pulling the `Klass*` with `java_lang_Class::as_Klass` and null-checking it, like _we already just did_. So really the assert is redundant and we can purge it.
>
> But this also suggests that whatever interaction with GC exists, it affects current code as well. I think it works with concurrent GCs through a different mechanism: the classes loaded during the GC and their mirrors would be either treated as implicitly live (e.g. via SATB invariants), or need to be specially keep-alived (Shenandoah's IU mode did this, IIRC).
This is what old CMS comment tried to say, I think:
// However, we might get across a klass that just changed during CMS concurrent
// marking if allocation occurred in the old generation.
//
// This is benign here, as we keep alive all CLDs that were loaded during the
// CMS concurrent phase in the class loading, i.e. they will be iterated over
// and kept alive during remark.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26477#discussion_r2231620237
More information about the hotspot-dev
mailing list