diff --git a/src/hotspot/share/oops/klass.cpp b/src/hotspot/share/oops/klass.cpp index a41f3540f39e8..256d4a53c9bf4 100644 --- a/src/hotspot/share/oops/klass.cpp +++ b/src/hotspot/share/oops/klass.cpp @@ -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() {