589 ref_klass->external_name(),
590 sel_method->is_abstract() ? "abstract " : "",
591 sel_method->is_protected() ? "protected " : "",
592 sel_method->is_private() ? "private " : "",
593 sel_method->external_name(),
594 (same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),
595 (same_module) ? "" : "; ",
596 (same_module) ? "" : sel_klass->class_in_module_of_loader()
597 );
598
599 // For private access check if there was a problem with nest host
600 // resolution, and if so report that as part of the message.
601 if (sel_method->is_private()) {
602 assert(ref_klass->is_instance_klass(), "must be");
603 assert(sel_klass->is_instance_klass(), "must be");
604 InstanceKlass* ref_ik = InstanceKlass::cast(ref_klass);
605 InstanceKlass* sel_ik = InstanceKlass::cast(sel_klass);
606 const char* nest_host_error_1 = ref_ik->nest_host_resolution_error();
607 const char* nest_host_error_2 = sel_ik->nest_host_resolution_error();
608 if (nest_host_error_1 != NULL || nest_host_error_2 != NULL) {
609 ss.print(", (");
610 if (nest_host_error_1 != NULL) {
611 ss.print("%s", nest_host_error_1);
612 if (nest_host_error_2 != NULL) {
613 ss.print(", %s", nest_host_error_2);
614 }
615 } else if (nest_host_error_2 != NULL) {
616 ss.print("%s", nest_host_error_2);
617 }
618 ss.print(")");
619 }
620 }
621
622 Exceptions::fthrow(THREAD_AND_LOCATION,
623 vmSymbols::java_lang_IllegalAccessError(),
624 "%s",
625 ss.as_string()
626 );
627 return;
628 }
629 }
630
631 Method* LinkResolver::resolve_method_statically(Bytecodes::Code code,
632 const constantPoolHandle& pool, int index, TRAPS) {
633 // This method is used only
634 // (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call),
635 // and
636 // (2) in Bytecode_invoke::static_target
637 // It appears to fail when applied to an invokeinterface call site.
638 // FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points.
946 ss.print("class %s tried to access %s%sfield %s.%s (%s%s%s)",
947 ref_klass->external_name(),
948 fd.is_protected() ? "protected " : "",
949 fd.is_private() ? "private " : "",
950 sel_klass->external_name(),
951 fd.name()->as_C_string(),
952 (same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),
953 (same_module) ? "" : "; ",
954 (same_module) ? "" : sel_klass->class_in_module_of_loader()
955 );
956 // For private access check if there was a problem with nest host
957 // resolution, and if so report that as part of the message.
958 if (fd.is_private()) {
959 assert(ref_klass->is_instance_klass(), "must be");
960 assert(sel_klass->is_instance_klass(), "must be");
961 InstanceKlass* ref_ik = InstanceKlass::cast(ref_klass);
962 InstanceKlass* sel_ik = InstanceKlass::cast(sel_klass);
963 const char* nest_host_error_1 = ref_ik->nest_host_resolution_error();
964 const char* nest_host_error_2 = sel_ik->nest_host_resolution_error();
965 if (nest_host_error_1 != NULL || nest_host_error_2 != NULL) {
966 ss.print(", (");
967 if (nest_host_error_1 != NULL) {
968 ss.print("%s", nest_host_error_1);
969 if (nest_host_error_2 != NULL) {
970 ss.print(", %s", nest_host_error_2);
971 }
972 } else if (nest_host_error_2 != NULL) {
973 ss.print("%s", nest_host_error_2);
974 }
975 ss.print(")");
976 }
977 }
978 Exceptions::fthrow(THREAD_AND_LOCATION,
979 vmSymbols::java_lang_IllegalAccessError(),
980 "%s",
981 ss.as_string()
982 );
983 return;
984 }
985 }
986
987 void LinkResolver::resolve_field_access(fieldDescriptor& fd, const constantPoolHandle& pool, int index, const methodHandle& method, Bytecodes::Code byte, TRAPS) {
988 LinkInfo link_info(pool, index, method, CHECK);
989 resolve_field(fd, link_info, byte, true, CHECK);
990 }
991
992 void LinkResolver::resolve_field(fieldDescriptor& fd,
993 const LinkInfo& link_info,
994 Bytecodes::Code byte, bool initialize_class,
995 TRAPS) {
|
589 ref_klass->external_name(),
590 sel_method->is_abstract() ? "abstract " : "",
591 sel_method->is_protected() ? "protected " : "",
592 sel_method->is_private() ? "private " : "",
593 sel_method->external_name(),
594 (same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),
595 (same_module) ? "" : "; ",
596 (same_module) ? "" : sel_klass->class_in_module_of_loader()
597 );
598
599 // For private access check if there was a problem with nest host
600 // resolution, and if so report that as part of the message.
601 if (sel_method->is_private()) {
602 assert(ref_klass->is_instance_klass(), "must be");
603 assert(sel_klass->is_instance_klass(), "must be");
604 InstanceKlass* ref_ik = InstanceKlass::cast(ref_klass);
605 InstanceKlass* sel_ik = InstanceKlass::cast(sel_klass);
606 const char* nest_host_error_1 = ref_ik->nest_host_resolution_error();
607 const char* nest_host_error_2 = sel_ik->nest_host_resolution_error();
608 if (nest_host_error_1 != NULL || nest_host_error_2 != NULL) {
609 ss.print(", (%s%s%s)",
610 (nest_host_error_1 != NULL) ? nest_host_error_1 : "",
611 (nest_host_error_1 != NULL && nest_host_error_2 != NULL) ? ", " : "",
612 (nest_host_error_2 != NULL) ? nest_host_error_2 : "");
613 }
614 }
615
616 Exceptions::fthrow(THREAD_AND_LOCATION,
617 vmSymbols::java_lang_IllegalAccessError(),
618 "%s",
619 ss.as_string()
620 );
621 return;
622 }
623 }
624
625 Method* LinkResolver::resolve_method_statically(Bytecodes::Code code,
626 const constantPoolHandle& pool, int index, TRAPS) {
627 // This method is used only
628 // (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call),
629 // and
630 // (2) in Bytecode_invoke::static_target
631 // It appears to fail when applied to an invokeinterface call site.
632 // FIXME: Remove this method and ciMethod::check_call; refactor to use the other LinkResolver entry points.
940 ss.print("class %s tried to access %s%sfield %s.%s (%s%s%s)",
941 ref_klass->external_name(),
942 fd.is_protected() ? "protected " : "",
943 fd.is_private() ? "private " : "",
944 sel_klass->external_name(),
945 fd.name()->as_C_string(),
946 (same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),
947 (same_module) ? "" : "; ",
948 (same_module) ? "" : sel_klass->class_in_module_of_loader()
949 );
950 // For private access check if there was a problem with nest host
951 // resolution, and if so report that as part of the message.
952 if (fd.is_private()) {
953 assert(ref_klass->is_instance_klass(), "must be");
954 assert(sel_klass->is_instance_klass(), "must be");
955 InstanceKlass* ref_ik = InstanceKlass::cast(ref_klass);
956 InstanceKlass* sel_ik = InstanceKlass::cast(sel_klass);
957 const char* nest_host_error_1 = ref_ik->nest_host_resolution_error();
958 const char* nest_host_error_2 = sel_ik->nest_host_resolution_error();
959 if (nest_host_error_1 != NULL || nest_host_error_2 != NULL) {
960 ss.print(", (%s%s%s)",
961 (nest_host_error_1 != NULL) ? nest_host_error_1 : "",
962 (nest_host_error_1 != NULL && nest_host_error_2 != NULL) ? ", " : "",
963 (nest_host_error_2 != NULL) ? nest_host_error_2 : "");
964 }
965 }
966 Exceptions::fthrow(THREAD_AND_LOCATION,
967 vmSymbols::java_lang_IllegalAccessError(),
968 "%s",
969 ss.as_string()
970 );
971 return;
972 }
973 }
974
975 void LinkResolver::resolve_field_access(fieldDescriptor& fd, const constantPoolHandle& pool, int index, const methodHandle& method, Bytecodes::Code byte, TRAPS) {
976 LinkInfo link_info(pool, index, method, CHECK);
977 resolve_field(fd, link_info, byte, true, CHECK);
978 }
979
980 void LinkResolver::resolve_field(fieldDescriptor& fd,
981 const LinkInfo& link_info,
982 Bytecodes::Code byte, bool initialize_class,
983 TRAPS) {
|