# HG changeset patch # User robm # Date 1509133162 -3600 # Node ID aa0313a30a38dd982b59785fc3ca053f3b12d0f3 # Parent d2e4c962b08af839b7b69c0491633ae9d171fe04 8180881: Better packaging of deserialization Reviewed-by: chegar, acorn diff -r d2e4c962b08a -r aa0313a30a38 src/share/vm/classfile/systemDictionary.cpp --- a/src/share/vm/classfile/systemDictionary.cpp Tue Nov 28 12:14:30 2017 +0100 +++ b/src/share/vm/classfile/systemDictionary.cpp Fri Oct 27 20:39:22 2017 +0100 @@ -139,6 +139,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 diff -r d2e4c962b08a -r aa0313a30a38 src/share/vm/classfile/systemDictionary.hpp --- a/src/share/vm/classfile/systemDictionary.hpp Tue Nov 28 12:14:30 2017 +0100 +++ b/src/share/vm/classfile/systemDictionary.hpp Fri Oct 27 20:39:22 2017 +0100 @@ -624,12 +624,15 @@ 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 static void add_to_hierarchy(instanceKlassHandle k, TRAPS); -private: // We pass in the hashtable index so we can calculate it outside of // the SystemDictionary_lock. diff -r d2e4c962b08a -r aa0313a30a38 src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Tue Nov 28 12:14:30 2017 +0100 +++ b/src/share/vm/classfile/vmSymbols.hpp Fri Oct 27 20:39:22 2017 +0100 @@ -112,6 +112,7 @@ template(sun_jkernel_DownloadManager, "sun/jkernel/DownloadManager") \ template(getBootClassPathEntryForClass_name, "getBootClassPathEntryForClass") \ template(sun_misc_PostVMInitHook, "sun/misc/PostVMInitHook") \ + template(sun_misc_Launcher_ExtClassLoader, "sun/misc/Launcher$ExtClassLoader") \ \ /* class file format tags */ \ template(tag_source_file, "SourceFile") \ diff -r d2e4c962b08a -r aa0313a30a38 src/share/vm/prims/jvm.cpp --- a/src/share/vm/prims/jvm.cpp Tue Nov 28 12:14:30 2017 +0100 +++ b/src/share/vm/prims/jvm.cpp Fri Oct 27 20:39:22 2017 +0100 @@ -3473,8 +3473,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()) { @@ -3482,7 +3483,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); } }