Skip to content

Commit bd1b942

Browse files
committedAug 10, 2023
8313905: Checked_cast assert in CDS compare_by_loader
Reviewed-by: dlong, iklam
1 parent 9b53251 commit bd1b942

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎src/hotspot/share/classfile/systemDictionaryShared.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,9 @@ class UnregisteredClassesDuplicationChecker : StackObj {
597597
ClassLoaderData* loader_b = b[0]->class_loader_data();
598598

599599
if (loader_a != loader_b) {
600-
return checked_cast<int>(intptr_t(loader_a) - intptr_t(loader_b));
600+
return primitive_compare(loader_a, loader_b);
601601
} else {
602-
return checked_cast<int>(intptr_t(a[0]) - intptr_t(b[0]));
602+
return primitive_compare(a[0], b[0]);
603603
}
604604
}
605605

‎src/hotspot/share/utilities/globalDefinitions.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,10 @@ template<typename K> bool primitive_equals(const K& k0, const K& k1) {
13341334
return k0 == k1;
13351335
}
13361336

1337+
template<typename K> int primitive_compare(const K& k0, const K& k1) {
1338+
return ((k0 < k1) ? -1 : (k0 == k1) ? 0 : 1);
1339+
}
1340+
13371341
//----------------------------------------------------------------------------------------------------
13381342

13391343
// Allow use of C++ thread_local when approved - see JDK-8282469.

0 commit comments

Comments
 (0)
Please sign in to comment.