Skip to content

Commit aa060f2

Browse files
committed
8342334: CDS: Scratch mirrors should not point to dead klasses
Reviewed-by: adinn, coleenp, iklam
1 parent 680dc5d commit aa060f2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/hotspot/share/cds/heapShared.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,13 @@ void HeapShared::set_scratch_java_mirror(Klass* k, oop mirror) {
386386
}
387387

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

0 commit comments

Comments
 (0)