8313905: Checked_cast assert in CDS compare_by_loader

Reviewed-by: dlong, iklam
This commit is contained in:
Coleen Phillimore 2023-08-10 15:25:00 +00:00
parent 9b53251131
commit bd1b942741
2 changed files with 6 additions and 2 deletions
src/hotspot/share

@ -597,9 +597,9 @@ public:
ClassLoaderData* loader_b = b[0]->class_loader_data();
if (loader_a != loader_b) {
return checked_cast<int>(intptr_t(loader_a) - intptr_t(loader_b));
return primitive_compare(loader_a, loader_b);
} else {
return checked_cast<int>(intptr_t(a[0]) - intptr_t(b[0]));
return primitive_compare(a[0], b[0]);
}
}

@ -1334,6 +1334,10 @@ template<typename K> bool primitive_equals(const K& k0, const K& k1) {
return k0 == k1;
}
template<typename K> int primitive_compare(const K& k0, const K& k1) {
return ((k0 < k1) ? -1 : (k0 == k1) ? 0 : 1);
}
//----------------------------------------------------------------------------------------------------
// Allow use of C++ thread_local when approved - see JDK-8282469.