8357525: Default CDS archive becomes non-deterministic after JDK-8305895

Reviewed-by: shade, coleenp
This commit is contained in:
Ioi Lam 2025-05-28 22:58:34 +00:00
parent dede3532f7
commit 2ec6ab347a

View File

@ -810,10 +810,18 @@ void Klass::remove_unshareable_info() {
set_class_loader_data(nullptr);
set_is_shared();
// FIXME: validation in Klass::hash_secondary_supers() may fail for shared klasses.
// Even though the bitmaps always match, the canonical order of elements in the table
// is not guaranteed to stay the same (see tie breaker during Robin Hood hashing in Klass::hash_insert).
//assert(compute_secondary_supers_bitmap(secondary_supers()) == _secondary_supers_bitmap, "broken table");
if (CDSConfig::is_dumping_classic_static_archive()) {
// "Classic" static archives are required to have deterministic contents.
// The elements in _secondary_supers are addresses in the ArchiveBuilder
// output buffer, so they should have deterministic values. If we rehash
// _secondary_supers, its elements will appear in a deterministic order.
//
// Note that the bitmap is guaranteed to be deterministic, regardless of the
// actual addresses of the elements in _secondary_supers. So rehashing shouldn't
// change it.
uintx bitmap = hash_secondary_supers(secondary_supers(), true);
assert(bitmap == _secondary_supers_bitmap, "bitmap should not be changed due to rehashing");
}
}
void Klass::remove_java_mirror() {