src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File bug_8166304 Cdiff src/share/vm/classfile/classFileParser.cpp

src/share/vm/classfile/classFileParser.cpp

Print this page

        

*** 4346,4363 **** } static void check_super_class_access(const InstanceKlass* this_klass, TRAPS) { assert(this_klass != NULL, "invariant"); const Klass* const super = this_klass->super(); if (super != NULL) { Reflection::VerifyClassAccessResults vca_result = Reflection::verify_class_access(this_klass, super, false); if (vca_result != Reflection::ACCESS_OK) { ResourceMark rm(THREAD); char* msg = Reflection::verify_class_access_msg(this_klass, super, vca_result); if (msg == NULL) { - ResourceMark rm(THREAD); Exceptions::fthrow( THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalAccessError(), "class %s cannot access its superclass %s", this_klass->external_name(), --- 4346,4383 ---- } static void check_super_class_access(const InstanceKlass* this_klass, TRAPS) { assert(this_klass != NULL, "invariant"); const Klass* const super = this_klass->super(); + if (super != NULL) { + // Throw an exception if superclass is in package jdk.internal.reflect and + // loader is neither the boot loader nor a subclass of the special reflection + // class loader + assert(super->is_instance_klass(), "super is not instance klass"); + PackageEntry* super_package = super->package(); + if (super_package != NULL) { + ClassLoaderData* this_cld = this_klass->class_loader_data(); + if (super_package->name() == vmSymbols::jdk_internal_reflect() && + !this_cld->is_the_null_class_loader_data() && + this_klass->class_loader() == + java_lang_ClassLoader::non_reflection_class_loader(this_klass->class_loader())) { + ResourceMark rm(THREAD); + Exceptions::fthrow( + THREAD_AND_LOCATION, + vmSymbols::java_lang_IllegalAccessError(), + "class %s loaded by %s cannot access jdk/internal/reflect superclass %s", + this_klass->external_name(), this_cld->loader_name(), super->external_name()); + } + } + Reflection::VerifyClassAccessResults vca_result = Reflection::verify_class_access(this_klass, super, false); if (vca_result != Reflection::ACCESS_OK) { ResourceMark rm(THREAD); char* msg = Reflection::verify_class_access_msg(this_klass, super, vca_result); if (msg == NULL) { Exceptions::fthrow( THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalAccessError(), "class %s cannot access its superclass %s", this_klass->external_name(),
src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File