8342334: CDS: Scratch mirrors should not point to dead klasses

Reviewed-by: adinn, coleenp, iklam
This commit is contained in:
Aleksey Shipilev 2024-10-21 08:04:12 +00:00
parent 680dc5d896
commit aa060f22d3

View File

@ -386,6 +386,13 @@ void HeapShared::set_scratch_java_mirror(Klass* k, oop mirror) {
}
void HeapShared::remove_scratch_objects(Klass* k) {
// Klass is being deallocated. Java mirror can still be alive, and it should not
// point to dead klass. We need to break the link from mirror to the Klass.
// See how InstanceKlass::deallocate_contents does it for normal mirrors.
oop mirror = _scratch_java_mirror_table->get_oop(k);
if (mirror != nullptr) {
java_lang_Class::set_klass(mirror, nullptr);
}
_scratch_java_mirror_table->remove_oop(k);
if (k->is_instance_klass()) {
_scratch_references_table->remove(InstanceKlass::cast(k)->constants());