8279993: Assert that a shared class is not loaded more than once

Reviewed-by: iklam, stuefe
(cherry picked from commit bb24c36759)
This commit is contained in:
Calvin Cheung
2023-05-18 16:02:55 +00:00
committed by Vitaly Provodin
parent aacb764042
commit c20e192b25
2 changed files with 4 additions and 1 deletions

View File

@@ -69,6 +69,7 @@
#include "prims/jvmtiExport.hpp"
#include "prims/methodHandles.hpp"
#include "runtime/arguments.hpp"
#include "runtime/atomic.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/java.hpp"
#include "runtime/javaCalls.hpp"
@@ -1143,7 +1144,8 @@ InstanceKlass* SystemDictionary::load_shared_class(InstanceKlass* ik,
PackageEntry* pkg_entry,
TRAPS) {
assert(ik != nullptr, "sanity");
assert(!ik->is_unshareable_info_restored(), "shared class can be loaded only once");
assert(!ik->is_unshareable_info_restored(), "shared class can be restored only once");
assert(Atomic::add(&ik->_shared_class_load_count, 1) == 1, "shared class loaded more than once");
Symbol* class_name = ik->name();
if (!is_shared_class_visible(class_name, ik, pkg_entry, class_loader)) {

View File

@@ -254,6 +254,7 @@ class InstanceKlass: public Klass {
#endif
NOT_PRODUCT(int _verify_count;) // to avoid redundant verifies
NOT_PRODUCT(volatile int _shared_class_load_count;) // ensure a shared class is loaded only once
// Method array.
Array<Method*>* _methods;