diff src/share/vm/memory/universe.cpp @ 6751:2a48c84f1d04

7197269: NPG: FollowReferences has no ClassLoader -> Class link to follow Summary: restore java/lang/ClassLoader.addClass() upcall Reviewed-by: sspitsyn, dcubed, jmasa
author coleenp
date Mon, 17 Sep 2012 10:46:59 -0400
parents 11fb740ce98f
children d8ce2825b193 8e47bac5643a fb19af007ffc
line wrap: on
line diff
--- a/src/share/vm/memory/universe.cpp	Thu Sep 13 21:20:26 2012 +0200
+++ b/src/share/vm/memory/universe.cpp	Mon Sep 17 10:46:59 2012 -0400
@@ -117,6 +117,7 @@
 oop Universe::_the_null_string                        = NULL;
 oop Universe::_the_min_jint_string                   = NULL;
 LatestMethodOopCache* Universe::_finalizer_register_cache = NULL;
+LatestMethodOopCache* Universe::_loader_addClass_cache    = NULL;
 ActiveMethodOopsCache* Universe::_reflect_invoke_cache    = NULL;
 oop Universe::_out_of_memory_error_java_heap          = NULL;
 oop Universe::_out_of_memory_error_perm_gen           = NULL;
@@ -228,6 +229,7 @@
   f->do_ptr((void**)&_the_empty_method_array);
   f->do_ptr((void**)&_the_empty_klass_array);
   _finalizer_register_cache->serialize(f);
+  _loader_addClass_cache->serialize(f);
   _reflect_invoke_cache->serialize(f);
 }
 
@@ -652,6 +654,7 @@
   // We have a heap so create the Method* caches before
   // Metaspace::initialize_shared_spaces() tries to populate them.
   Universe::_finalizer_register_cache = new LatestMethodOopCache();
+  Universe::_loader_addClass_cache    = new LatestMethodOopCache();
   Universe::_reflect_invoke_cache     = new ActiveMethodOopsCache();
 
   if (UseSharedSpaces) {
@@ -1041,6 +1044,16 @@
   }
   Universe::_reflect_invoke_cache->init(k_h(), m, CHECK_false);
 
+  // Setup method for registering loaded classes in class loader vector
+  InstanceKlass::cast(SystemDictionary::ClassLoader_klass())->link_class(CHECK_false);
+  m = InstanceKlass::cast(SystemDictionary::ClassLoader_klass())->find_method(vmSymbols::addClass_name(), vmSymbols::class_void_signature());
+  if (m == NULL || m->is_static()) {
+    THROW_MSG_(vmSymbols::java_lang_NoSuchMethodException(),
+      "java.lang.ClassLoader.addClass", false);
+  }
+  Universe::_loader_addClass_cache->init(
+    SystemDictionary::ClassLoader_klass(), m, CHECK_false);
+
   // The folowing is initializing converter functions for serialization in
   // JVM.cpp. If we clean up the StrictMath code above we may want to find
   // a better solution for this as well.