changeset 47614:0ecfd6c951a6

8185694: Replace SystemDictionaryShared::_java_platform_loader with SystemDictionary::is_platform_class_loader() Summary: added the creation of _java_platform_loader Reviewed-by: iklam, coleenp, mchung, dholmes, jiangli
author ccheung
date Tue, 10 Oct 2017 14:38:56 -0700
parents af241e3e5a13
children 6210a27c3704
files src/hotspot/share/classfile/systemDictionary.cpp src/hotspot/share/classfile/systemDictionary.hpp src/hotspot/share/classfile/vmSymbols.hpp src/hotspot/share/runtime/thread.cpp
diffstat 4 files changed, 30 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/systemDictionary.cpp	Tue Oct 10 11:52:42 2017 -0700
+++ b/src/hotspot/share/classfile/systemDictionary.cpp	Tue Oct 10 14:38:56 2017 -0700
@@ -104,6 +104,7 @@
 InstanceKlass*      SystemDictionary::_box_klasses[T_VOID+1]      =  { NULL /*, NULL...*/ };
 
 oop         SystemDictionary::_java_system_loader         =  NULL;
+oop         SystemDictionary::_java_platform_loader       =  NULL;
 
 bool        SystemDictionary::_has_loadClassInternal      =  false;
 bool        SystemDictionary::_has_checkPackageAccess     =  false;
@@ -117,27 +118,38 @@
 
 
 // ----------------------------------------------------------------------------
-// Java-level SystemLoader
+// Java-level SystemLoader and PlatformLoader
 
 oop SystemDictionary::java_system_loader() {
   return _java_system_loader;
 }
 
-void SystemDictionary::compute_java_system_loader(TRAPS) {
-  Klass* system_klass = WK_KLASS(ClassLoader_klass);
+oop SystemDictionary::java_platform_loader() {
+  return _java_platform_loader;
+}
+
+void SystemDictionary::compute_java_loaders(TRAPS) {
   JavaValue result(T_OBJECT);
+  InstanceKlass* class_loader_klass = SystemDictionary::ClassLoader_klass();
   JavaCalls::call_static(&result,
-                         WK_KLASS(ClassLoader_klass),
+                         class_loader_klass,
                          vmSymbols::getSystemClassLoader_name(),
                          vmSymbols::void_classloader_signature(),
                          CHECK);
 
   _java_system_loader = (oop)result.get_jobject();
 
+  JavaCalls::call_static(&result,
+                         class_loader_klass,
+                         vmSymbols::getPlatformClassLoader_name(),
+                         vmSymbols::void_classloader_signature(),
+                         CHECK);
+
+  _java_platform_loader = (oop)result.get_jobject();
+
   CDS_ONLY(SystemDictionaryShared::initialize(CHECK);)
 }
 
-
 ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, TRAPS) {
   if (class_loader() == NULL) return ClassLoaderData::the_null_class_loader_data();
   return ClassLoaderDataGraph::find_or_create(class_loader, THREAD);
@@ -169,7 +181,7 @@
     return false;
   }
   return (class_loader->klass() == SystemDictionary::jdk_internal_loader_ClassLoaders_AppClassLoader_klass() ||
-          class_loader == _java_system_loader);
+       class_loader == _java_system_loader);
 }
 
 // Returns true if the passed class loader is the platform class loader.
@@ -1940,6 +1952,7 @@
 
 void SystemDictionary::roots_oops_do(OopClosure* strong, OopClosure* weak) {
   strong->do_oop(&_java_system_loader);
+  strong->do_oop(&_java_platform_loader);
   strong->do_oop(&_system_loader_lock_obj);
   CDS_ONLY(SystemDictionaryShared::roots_oops_do(strong);)
 
@@ -1964,6 +1977,7 @@
 
 void SystemDictionary::oops_do(OopClosure* f) {
   f->do_oop(&_java_system_loader);
+  f->do_oop(&_java_platform_loader);
   f->do_oop(&_system_loader_lock_obj);
   CDS_ONLY(SystemDictionaryShared::oops_do(f);)
 
--- a/src/hotspot/share/classfile/systemDictionary.hpp	Tue Oct 10 11:52:42 2017 -0700
+++ b/src/hotspot/share/classfile/systemDictionary.hpp	Tue Oct 10 14:38:56 2017 -0700
@@ -484,11 +484,14 @@
   static bool Object_klass_loaded()         { return WK_KLASS(Object_klass) != NULL; }
   static bool ClassLoader_klass_loaded()    { return WK_KLASS(ClassLoader_klass) != NULL; }
 
-  // Returns default system loader
+  // Returns java system loader
   static oop java_system_loader();
 
-  // Compute the default system loader
-  static void compute_java_system_loader(TRAPS);
+  // Returns java platform loader
+  static oop java_platform_loader();
+
+  // Compute the java system and platform loaders
+  static void compute_java_loaders(TRAPS);
 
   // Register a new class loader
   static ClassLoaderData* register_loader(Handle class_loader, TRAPS);
@@ -700,6 +703,7 @@
   static InstanceKlass* _box_klasses[T_VOID+1];
 
   static oop  _java_system_loader;
+  static oop  _java_platform_loader;
 
   static bool _has_loadClassInternal;
   static bool _has_checkPackageAccess;
--- a/src/hotspot/share/classfile/vmSymbols.hpp	Tue Oct 10 11:52:42 2017 -0700
+++ b/src/hotspot/share/classfile/vmSymbols.hpp	Tue Oct 10 14:38:56 2017 -0700
@@ -371,6 +371,7 @@
   template(deadChild_name,                            "deadChild")                                \
   template(getFromClass_name,                         "getFromClass")                             \
   template(dispatch_name,                             "dispatch")                                 \
+  template(getPlatformClassLoader_name,               "getPlatformClassLoader")                   \
   template(getSystemClassLoader_name,                 "getSystemClassLoader")                     \
   template(fillInStackTrace_name,                     "fillInStackTrace")                         \
   template(getCause_name,                             "getCause")                                 \
--- a/src/hotspot/share/runtime/thread.cpp	Tue Oct 10 11:52:42 2017 -0700
+++ b/src/hotspot/share/runtime/thread.cpp	Tue Oct 10 14:38:56 2017 -0700
@@ -3751,8 +3751,8 @@
   // Final system initialization including security manager and system class loader
   call_initPhase3(CHECK_JNI_ERR);
 
-  // cache the system class loader
-  SystemDictionary::compute_java_system_loader(CHECK_(JNI_ERR));
+  // cache the system and platform class loaders
+  SystemDictionary::compute_java_loaders(CHECK_JNI_ERR);
 
 #if INCLUDE_JVMCI
   if (EnableJVMCI) {