< prev index next >

src/hotspot/share/classfile/classFileParser.cpp

Print this page
rev 50260 : 8199940: Print more information about class loaders in IllegalAccessErrors.
ReviewedBy: lfoltan


4509           vmSymbols::java_lang_IllegalAccessError(),
4510           "class %s loaded by %s cannot access jdk/internal/reflect superclass %s",
4511           this_klass->external_name(),
4512           this_klass->class_loader_data()->loader_name(),
4513           super->external_name());
4514         return;
4515       }
4516     }
4517 
4518     Reflection::VerifyClassAccessResults vca_result =
4519       Reflection::verify_class_access(this_klass, InstanceKlass::cast(super), false);
4520     if (vca_result != Reflection::ACCESS_OK) {
4521       ResourceMark rm(THREAD);
4522       char* msg = Reflection::verify_class_access_msg(this_klass,
4523                                                       InstanceKlass::cast(super),
4524                                                       vca_result);
4525       if (msg == NULL) {
4526         Exceptions::fthrow(
4527           THREAD_AND_LOCATION,
4528           vmSymbols::java_lang_IllegalAccessError(),
4529           "class %s cannot access its superclass %s",
4530           this_klass->external_name(),
4531           super->external_name());

4532       } else {
4533         // Add additional message content.
4534         Exceptions::fthrow(
4535           THREAD_AND_LOCATION,
4536           vmSymbols::java_lang_IllegalAccessError(),
4537           "superclass access check failed: %s",
4538           msg);
4539       }
4540     }
4541   }
4542 }
4543 
4544 
4545 static void check_super_interface_access(const InstanceKlass* this_klass, TRAPS) {
4546   assert(this_klass != NULL, "invariant");
4547   const Array<Klass*>* const local_interfaces = this_klass->local_interfaces();
4548   const int lng = local_interfaces->length();
4549   for (int i = lng - 1; i >= 0; i--) {
4550     Klass* const k = local_interfaces->at(i);
4551     assert (k != NULL && k->is_interface(), "invalid interface");
4552     Reflection::VerifyClassAccessResults vca_result =
4553       Reflection::verify_class_access(this_klass, InstanceKlass::cast(k), false);
4554     if (vca_result != Reflection::ACCESS_OK) {
4555       ResourceMark rm(THREAD);
4556       char* msg = Reflection::verify_class_access_msg(this_klass,
4557                                                       InstanceKlass::cast(k),
4558                                                       vca_result);
4559       if (msg == NULL) {
4560         Exceptions::fthrow(
4561           THREAD_AND_LOCATION,
4562           vmSymbols::java_lang_IllegalAccessError(),
4563           "class %s cannot access its superinterface %s",
4564           this_klass->external_name(),
4565           k->external_name());
4566       } else {
4567         // Add additional message content.
4568         Exceptions::fthrow(
4569           THREAD_AND_LOCATION,
4570           vmSymbols::java_lang_IllegalAccessError(),
4571           "superinterface check failed: %s",
4572           msg);
4573       }
4574     }
4575   }
4576 }
4577 
4578 
4579 static void check_final_method_override(const InstanceKlass* this_klass, TRAPS) {
4580   assert(this_klass != NULL, "invariant");
4581   const Array<Method*>* const methods = this_klass->methods();
4582   const int num_methods = methods->length();
4583 
4584   // go thru each method and check if it overrides a final method
4585   for (int index = 0; index < num_methods; index++) {




4509           vmSymbols::java_lang_IllegalAccessError(),
4510           "class %s loaded by %s cannot access jdk/internal/reflect superclass %s",
4511           this_klass->external_name(),
4512           this_klass->class_loader_data()->loader_name(),
4513           super->external_name());
4514         return;
4515       }
4516     }
4517 
4518     Reflection::VerifyClassAccessResults vca_result =
4519       Reflection::verify_class_access(this_klass, InstanceKlass::cast(super), false);
4520     if (vca_result != Reflection::ACCESS_OK) {
4521       ResourceMark rm(THREAD);
4522       char* msg = Reflection::verify_class_access_msg(this_klass,
4523                                                       InstanceKlass::cast(super),
4524                                                       vca_result);
4525       if (msg == NULL) {
4526         Exceptions::fthrow(
4527           THREAD_AND_LOCATION,
4528           vmSymbols::java_lang_IllegalAccessError(),
4529           "class %s cannot access its %ssuperclass %s",
4530           this_klass->class_loader_and_module_name(),
4531           super->is_abstract() ? "abstract " : "",
4532           super->class_loader_and_module_name());
4533       } else {
4534         // Add additional message content.
4535         Exceptions::fthrow(
4536           THREAD_AND_LOCATION,
4537           vmSymbols::java_lang_IllegalAccessError(),
4538           "superclass access check failed: %s",
4539           msg);
4540       }
4541     }
4542   }
4543 }
4544 
4545 
4546 static void check_super_interface_access(const InstanceKlass* this_klass, TRAPS) {
4547   assert(this_klass != NULL, "invariant");
4548   const Array<Klass*>* const local_interfaces = this_klass->local_interfaces();
4549   const int lng = local_interfaces->length();
4550   for (int i = lng - 1; i >= 0; i--) {
4551     Klass* const k = local_interfaces->at(i);
4552     assert (k != NULL && k->is_interface(), "invalid interface");
4553     Reflection::VerifyClassAccessResults vca_result =
4554       Reflection::verify_class_access(this_klass, InstanceKlass::cast(k), false);
4555     if (vca_result != Reflection::ACCESS_OK) {
4556       ResourceMark rm(THREAD);
4557       char* msg = Reflection::verify_class_access_msg(this_klass,
4558                                                       InstanceKlass::cast(k),
4559                                                       vca_result);
4560       if (msg == NULL) {
4561         Exceptions::fthrow(
4562           THREAD_AND_LOCATION,
4563           vmSymbols::java_lang_IllegalAccessError(),
4564           "class %s cannot access its superinterface %s",
4565           this_klass->class_loader_and_module_name(),
4566           k->class_loader_and_module_name());
4567       } else {
4568         // Add additional message content.
4569         Exceptions::fthrow(
4570           THREAD_AND_LOCATION,
4571           vmSymbols::java_lang_IllegalAccessError(),
4572           "superinterface check failed: %s",
4573           msg);
4574       }
4575     }
4576   }
4577 }
4578 
4579 
4580 static void check_final_method_override(const InstanceKlass* this_klass, TRAPS) {
4581   assert(this_klass != NULL, "invariant");
4582   const Array<Method*>* const methods = this_klass->methods();
4583   const int num_methods = methods->length();
4584 
4585   // go thru each method and check if it overrides a final method
4586   for (int index = 0; index < num_methods; index++) {


< prev index next >