changeset 5824:13fda368122a

8180881: Better packaging of deserialization Summary: Contains is_ext_class_loader_data addition from 7198429 Reviewed-by: chegar, acorn
author robm
date Tue, 10 Apr 2018 22:46:22 +0100
parents f0e7f5612512
children 8b0587cd6277
files src/share/vm/classfile/classFileParser.cpp src/share/vm/classfile/systemDictionary.cpp src/share/vm/classfile/systemDictionary.hpp src/share/vm/oops/methodOop.cpp src/share/vm/prims/jvm.cpp
diffstat 5 files changed, 23 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/classfile/classFileParser.cpp	Thu Feb 15 19:53:10 2018 +0000
+++ b/src/share/vm/classfile/classFileParser.cpp	Tue Apr 10 22:46:22 2018 +0100
@@ -1779,8 +1779,7 @@
   vmSymbols::SID sid = vmSymbols::find_sid(name);
   // Privileged code can use all annotations.  Other code silently drops some.
   const bool privileged = class_loader.is_null() || is_anonymous ||
-                          class_loader()->klass()->klass_part()->name() ==
-                            vmSymbols::sun_misc_Launcher_ExtClassLoader();
+                          SystemDictionary::is_ext_class_loader(class_loader);
   switch (sid) {
   case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_ForceInline_signature):
     if (_location != _in_method)  break;  // only allow for methods
--- a/src/share/vm/classfile/systemDictionary.cpp	Thu Feb 15 19:53:10 2018 +0000
+++ b/src/share/vm/classfile/systemDictionary.cpp	Tue Apr 10 22:46:22 2018 +0100
@@ -145,6 +145,17 @@
    }
    return false;
 }
+
+/**
+ * Returns true if the passed class loader is the extension class loader.
+ */
+bool SystemDictionary::is_ext_class_loader(Handle class_loader) {
+  if (class_loader.is_null()) {
+    return false;
+  }
+  return (class_loader->klass()->klass_part()->name() == vmSymbols::sun_misc_Launcher_ExtClassLoader());
+}
+
 // ----------------------------------------------------------------------------
 // Resolving of classes
 
--- a/src/share/vm/classfile/systemDictionary.hpp	Thu Feb 15 19:53:10 2018 +0000
+++ b/src/share/vm/classfile/systemDictionary.hpp	Tue Apr 10 22:46:22 2018 +0100
@@ -612,6 +612,10 @@
   static bool is_parallelCapable(Handle class_loader);
   static bool is_parallelDefine(Handle class_loader);
 
+public:
+  static bool is_ext_class_loader(Handle class_loader);
+
+private:
   static klassOop find_shared_class(Symbol* class_name);
 
   // Setup link to hierarchy
@@ -622,7 +626,6 @@
                                     Handle initiating_loader);
   static void post_class_unload_events(BoolObjectClosure* is_alive);
 
-private:
   // We pass in the hashtable index so we can calculate it outside of
   // the SystemDictionary_lock.
 
--- a/src/share/vm/oops/methodOop.cpp	Thu Feb 15 19:53:10 2018 +0000
+++ b/src/share/vm/oops/methodOop.cpp	Tue Apr 10 22:46:22 2018 +0100
@@ -1106,13 +1106,13 @@
   // because we are not loading from core libraries
   // exception: the AES intrinsics come from lib/ext/sunjce_provider.jar
   // which does not use the class default class loader so we check for its loader here
-  if ((instanceKlass::cast(holder)->class_loader() != NULL) &&
-       instanceKlass::cast(holder)->class_loader()->klass()->klass_part()->name() != vmSymbols::sun_misc_Launcher_ExtClassLoader()) {
+  instanceKlass* ik = instanceKlass::cast(holder);
+  if ((ik->class_loader() != NULL) && !SystemDictionary::is_ext_class_loader(ik->class_loader())) {
     return vmSymbols::NO_SID;   // regardless of name, no intrinsics here
   }
 
   // see if the klass name is well-known:
-  Symbol* klass_name = instanceKlass::cast(holder)->name();
+  Symbol* klass_name = ik->name();
   return vmSymbols::find_sid(klass_name);
 }
 
--- a/src/share/vm/prims/jvm.cpp	Thu Feb 15 19:53:10 2018 +0000
+++ b/src/share/vm/prims/jvm.cpp	Tue Apr 10 22:46:22 2018 +0100
@@ -3488,8 +3488,9 @@
 JVM_END
 
 
-// Return the first non-null class loader up the execution stack, or null
-// if only code from the null class loader is on the stack.
+// Returns first non-privileged class loader on the stack (excluding reflection
+// generated frames) or null if only classes loaded by the boot class loader
+// and extension class loader are found on the stack.
 
 JVM_ENTRY(jobject, JVM_LatestUserDefinedLoader(JNIEnv *env))
   for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) {
@@ -3497,7 +3498,7 @@
     vfst.skip_reflection_related_frames(); // Only needed for 1.4 reflection
     klassOop holder = vfst.method()->method_holder();
     oop loader = instanceKlass::cast(holder)->class_loader();
-    if (loader != NULL) {
+    if (loader != NULL && !SystemDictionary::is_ext_class_loader(loader)) {
       return JNIHandles::make_local(env, loader);
     }
   }