--- old/src/hotspot/share/classfile/systemDictionary.cpp 2018-03-26 13:40:53.922001585 -0400 +++ new/src/hotspot/share/classfile/systemDictionary.cpp 2018-03-26 13:40:53.535965922 -0400 @@ -1012,7 +1012,9 @@ CHECK_NULL); if (host_klass != NULL && k != NULL) { - // If it's anonymous, initialize it now, since nobody else will. + // Anonymous classes must update ClassLoaderData holder (was host_klass loader) + // so that they can be unloaded when the mirror is no longer referenced. + k->class_loader_data()->update_holder(Handle(THREAD, k->java_mirror())); { MutexLocker mu_r(Compile_lock, THREAD); @@ -1032,6 +1034,8 @@ if (cp_patches != NULL) { k->constants()->patch_resolved_references(cp_patches); } + + // If it's anonymous, initialize it now, since nobody else will. k->eager_initialize(CHECK_NULL); // notify jvmti