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

src/share/vm/classfile/classFileParser.cpp

Print this page




4331     // Finally add local interfaces
4332     append_interfaces(result, local_ifs);
4333 
4334     // length will be less than the max_transitive_size if duplicates were removed
4335     const int length = result->length();
4336     assert(length <= max_transitive_size, "just checking");
4337     Array<Klass*>* const new_result =
4338       MetadataFactory::new_array<Klass*>(loader_data, length, CHECK_NULL);
4339     for (int i = 0; i < length; i++) {
4340       Klass* const e = result->at(i);
4341       assert(e != NULL, "just checking");
4342       new_result->at_put(i, e);
4343     }
4344     return new_result;
4345   }
4346 }
4347 
4348 static void check_super_class_access(const InstanceKlass* this_klass, TRAPS) {
4349   assert(this_klass != NULL, "invariant");
4350   const Klass* const super = this_klass->super();

4351   if (super != NULL) {




















4352     Reflection::VerifyClassAccessResults vca_result =
4353       Reflection::verify_class_access(this_klass, super, false);
4354     if (vca_result != Reflection::ACCESS_OK) {
4355       ResourceMark rm(THREAD);
4356       char* msg =  Reflection::verify_class_access_msg(this_klass, super, vca_result);
4357       if (msg == NULL) {
4358         ResourceMark rm(THREAD);
4359         Exceptions::fthrow(
4360           THREAD_AND_LOCATION,
4361           vmSymbols::java_lang_IllegalAccessError(),
4362           "class %s cannot access its superclass %s",
4363           this_klass->external_name(),
4364           super->external_name());
4365       } else {
4366         // Add additional message content.
4367         Exceptions::fthrow(
4368           THREAD_AND_LOCATION,
4369           vmSymbols::java_lang_IllegalAccessError(),
4370           "superclass access check failed: %s",
4371           msg);
4372       }
4373     }
4374   }
4375 }
4376 
4377 
4378 static void check_super_interface_access(const InstanceKlass* this_klass, TRAPS) {




4331     // Finally add local interfaces
4332     append_interfaces(result, local_ifs);
4333 
4334     // length will be less than the max_transitive_size if duplicates were removed
4335     const int length = result->length();
4336     assert(length <= max_transitive_size, "just checking");
4337     Array<Klass*>* const new_result =
4338       MetadataFactory::new_array<Klass*>(loader_data, length, CHECK_NULL);
4339     for (int i = 0; i < length; i++) {
4340       Klass* const e = result->at(i);
4341       assert(e != NULL, "just checking");
4342       new_result->at_put(i, e);
4343     }
4344     return new_result;
4345   }
4346 }
4347 
4348 static void check_super_class_access(const InstanceKlass* this_klass, TRAPS) {
4349   assert(this_klass != NULL, "invariant");
4350   const Klass* const super = this_klass->super();
4351 
4352   if (super != NULL) {
4353     // Throw an exception if superclass is in package jdk.internal.reflect and
4354     // loader is neither the boot loader nor a subclass of the special reflection
4355     // class loader
4356     assert(super->is_instance_klass(), "super is not instance klass");
4357     PackageEntry* super_package = super->package();
4358     if (super_package != NULL) {
4359       ClassLoaderData* this_cld = this_klass->class_loader_data();
4360       if (super_package->name() == vmSymbols::jdk_internal_reflect() &&
4361           !this_cld->is_the_null_class_loader_data() &&
4362           this_klass->class_loader() ==
4363             java_lang_ClassLoader::non_reflection_class_loader(this_klass->class_loader())) {
4364         ResourceMark rm(THREAD);
4365         Exceptions::fthrow(
4366           THREAD_AND_LOCATION,
4367           vmSymbols::java_lang_IllegalAccessError(),
4368           "class %s loaded by %s cannot access jdk/internal/reflect superclass %s",
4369           this_klass->external_name(), this_cld->loader_name(), super->external_name());
4370       }
4371     }
4372 
4373     Reflection::VerifyClassAccessResults vca_result =
4374       Reflection::verify_class_access(this_klass, super, false);
4375     if (vca_result != Reflection::ACCESS_OK) {
4376       ResourceMark rm(THREAD);
4377       char* msg =  Reflection::verify_class_access_msg(this_klass, super, vca_result);
4378       if (msg == NULL) {

4379         Exceptions::fthrow(
4380           THREAD_AND_LOCATION,
4381           vmSymbols::java_lang_IllegalAccessError(),
4382           "class %s cannot access its superclass %s",
4383           this_klass->external_name(),
4384           super->external_name());
4385       } else {
4386         // Add additional message content.
4387         Exceptions::fthrow(
4388           THREAD_AND_LOCATION,
4389           vmSymbols::java_lang_IllegalAccessError(),
4390           "superclass access check failed: %s",
4391           msg);
4392       }
4393     }
4394   }
4395 }
4396 
4397 
4398 static void check_super_interface_access(const InstanceKlass* this_klass, TRAPS) {


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