Skip to content

Commit 2ec6ab3

Browse files
committed
8357525: Default CDS archive becomes non-deterministic after JDK-8305895
Reviewed-by: shade, coleenp
1 parent dede353 commit 2ec6ab3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/hotspot/share/oops/klass.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,18 @@ void Klass::remove_unshareable_info() {
810810
set_class_loader_data(nullptr);
811811
set_is_shared();
812812

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

819827
void Klass::remove_java_mirror() {

0 commit comments

Comments
 (0)