6888880: JKernel VM to inject the sun.jkernel.DownloadManager as a boot classloader hook
authormchung
Wed, 25 Nov 2009 08:37:04 -0800
changeset 4485 76684005deef
parent 4446 73f83d9d3e9c
child 4486 b20d43a2cab9
child 4487 de1359156181
6888880: JKernel VM to inject the sun.jkernel.DownloadManager as a boot classloader hook Summary: Call sun.jkernel.DownloadManager.setBootClassLoaderHook during the kernel VM initialization Reviewed-by: alanb, coleenp, acorn
hotspot/src/share/vm/classfile/vmSymbols.hpp
hotspot/src/share/vm/runtime/thread.cpp
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Mon Nov 23 16:24:35 2009 -0500
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Nov 25 08:37:04 2009 -0800
@@ -104,6 +104,7 @@
   template(java_lang_AssertionStatusDirectives,       "java/lang/AssertionStatusDirectives")      \
   template(sun_jkernel_DownloadManager,               "sun/jkernel/DownloadManager")              \
   template(getBootClassPathEntryForClass_name,        "getBootClassPathEntryForClass")            \
+  template(setBootClassLoaderHook_name,               "setBootClassLoaderHook")                   \
                                                                                                   \
   /* class file format tags */                                                                    \
   template(tag_source_file,                           "SourceFile")                               \
--- a/hotspot/src/share/vm/runtime/thread.cpp	Mon Nov 23 16:24:35 2009 -0500
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Wed Nov 25 08:37:04 2009 -0800
@@ -884,6 +884,22 @@
                                          vmSymbolHandles::void_method_signature(), CHECK);
 }
 
+#ifdef KERNEL
+static void set_jkernel_boot_classloader_hook(TRAPS) {
+  klassOop k = SystemDictionary::sun_jkernel_DownloadManager_klass();
+  instanceKlassHandle klass (THREAD, k);
+
+  if (k == NULL) {
+    // sun.jkernel.DownloadManager may not present in the JDK; just return
+    return;
+  }
+
+  JavaValue result(T_VOID);
+  JavaCalls::call_static(&result, klass, vmSymbolHandles::setBootClassLoaderHook_name(),
+                                         vmSymbolHandles::void_method_signature(), CHECK);
+}
+#endif // KERNEL
+
 static void reset_vm_info_property(TRAPS) {
   // the vm info string
   ResourceMark rm(THREAD);
@@ -3102,6 +3118,12 @@
     vm_exit_during_initialization(Handle(THREAD, PENDING_EXCEPTION));
   }
 
+#ifdef KERNEL
+  if (JDK_Version::is_gte_jdk17x_version()) {
+    set_jkernel_boot_classloader_hook(THREAD);
+  }
+#endif // KERNEL
+
 #ifndef SERIALGC
   // Support for ConcurrentMarkSweep. This should be cleaned up
   // and better encapsulated. The ugly nested if test would go away