diff -r d193d58ae79d -r 5afdd1100a20 src/hotspot/share/classfile/systemDictionary.cpp --- a/src/hotspot/share/classfile/systemDictionary.cpp Tue Jan 15 16:40:31 2019 -0500 +++ b/src/hotspot/share/classfile/systemDictionary.cpp Tue Jan 15 22:54:09 2019 +0100 @@ -860,8 +860,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); @@ -2179,6 +2186,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