--- a/src/hotspot/share/classfile/systemDictionary.cpp Tue Aug 28 13:22:57 2018 +0530
+++ b/src/hotspot/share/classfile/systemDictionary.cpp Mon Sep 10 16:49:01 2018 -0400
@@ -861,8 +861,15 @@
check_constraints(d_hash, k, class_loader, false, THREAD);
// Need to check for a PENDING_EXCEPTION again; check_constraints
- // can throw and doesn't use the CHECK macro.
+ // can throw but we may have to remove entry from the placeholder table below.
if (!HAS_PENDING_EXCEPTION) {
+ // Record dependency for non-parent delegation.
+ // This recording keeps the defining class loader of the klass (k) found
+ // from being unloaded while the initiating class loader is loaded
+ // even if the reference to the defining class loader is dropped
+ // before references to the initiating class loader.
+ loader_data->record_dependency(k);
+
{ // Grabbing the Compile_lock prevents systemDictionary updates
// during compilations.
MutexLocker mu(Compile_lock, THREAD);
@@ -2177,6 +2184,7 @@
InstanceKlass* sd_check = find_class(d_hash, name, dictionary);
if (sd_check == NULL) {
dictionary->add_klass(d_hash, name, k);
+
notice_modification();
}
#ifdef ASSERT