< prev index next >
src/hotspot/share/classfile/systemDictionary.cpp
Print this page
@@ -1010,11 +1010,13 @@
host_klass,
cp_patches,
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);
// Add to class hierarchy, initialize vtables, and do possible
@@ -1030,10 +1032,12 @@
// Rewrite and patch constant pool here.
k->link_class(CHECK_NULL);
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
if (JvmtiExport::should_post_class_load()) {
assert(THREAD->is_Java_thread(), "thread->is_Java_thread()");
< prev index next >