594 sel_klass,
595 flags,
596 true, false, CHECK);
597 // Any existing exceptions that may have been thrown
598 // have been allowed to propagate.
599 if (!can_access) {
600 ResourceMark rm(THREAD);
601 stringStream ss;
602 bool same_module = (sel_klass->module() == ref_klass->module());
603 ss.print("class %s tried to access %s%s%smethod '%s' (%s%s%s)",
604 ref_klass->external_name(),
605 sel_method->is_abstract() ? "abstract " : "",
606 sel_method->is_protected() ? "protected " : "",
607 sel_method->is_private() ? "private " : "",
608 sel_method->external_name(),
609 (same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),
610 (same_module) ? "" : "; ",
611 (same_module) ? "" : sel_klass->class_in_module_of_loader()
612 );
613
614 // For private access check if there was a problem with nest host
615 // resolution, and if so report that as part of the message.
616 if (sel_method->is_private()) {
617 print_nest_host_error_on(&ss, ref_klass, sel_klass, THREAD);
618 }
619
620 Exceptions::fthrow(THREAD_AND_LOCATION,
621 vmSymbols::java_lang_IllegalAccessError(),
622 "%s",
623 ss.as_string()
624 );
625 return;
626 }
627 }
628
629 Method* LinkResolver::resolve_method_statically(Bytecodes::Code code,
630 const constantPoolHandle& pool, int index, TRAPS) {
631 // This method is used only
632 // (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call),
633 // and
634 // (2) in Bytecode_invoke::static_target
934 resolved_klass,
935 sel_klass,
936 fd.access_flags(),
937 true, false, CHECK);
938 // Any existing exceptions that may have been thrown, for example LinkageErrors
939 // from nest-host resolution, have been allowed to propagate.
940 if (!can_access) {
941 bool same_module = (sel_klass->module() == ref_klass->module());
942 ResourceMark rm(THREAD);
943 stringStream ss;
944 ss.print("class %s tried to access %s%sfield %s.%s (%s%s%s)",
945 ref_klass->external_name(),
946 fd.is_protected() ? "protected " : "",
947 fd.is_private() ? "private " : "",
948 sel_klass->external_name(),
949 fd.name()->as_C_string(),
950 (same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),
951 (same_module) ? "" : "; ",
952 (same_module) ? "" : sel_klass->class_in_module_of_loader()
953 );
954 // For private access check if there was a problem with nest host
955 // resolution, and if so report that as part of the message.
956 if (fd.is_private()) {
957 print_nest_host_error_on(&ss, ref_klass, sel_klass, THREAD);
958 }
959 Exceptions::fthrow(THREAD_AND_LOCATION,
960 vmSymbols::java_lang_IllegalAccessError(),
961 "%s",
962 ss.as_string()
963 );
964 return;
965 }
966 }
967
968 void LinkResolver::resolve_field_access(fieldDescriptor& fd, const constantPoolHandle& pool, int index, const methodHandle& method, Bytecodes::Code byte, TRAPS) {
969 LinkInfo link_info(pool, index, method, CHECK);
970 resolve_field(fd, link_info, byte, true, CHECK);
971 }
972
973 void LinkResolver::resolve_field(fieldDescriptor& fd,
974 const LinkInfo& link_info,
|
594 sel_klass,
595 flags,
596 true, false, CHECK);
597 // Any existing exceptions that may have been thrown
598 // have been allowed to propagate.
599 if (!can_access) {
600 ResourceMark rm(THREAD);
601 stringStream ss;
602 bool same_module = (sel_klass->module() == ref_klass->module());
603 ss.print("class %s tried to access %s%s%smethod '%s' (%s%s%s)",
604 ref_klass->external_name(),
605 sel_method->is_abstract() ? "abstract " : "",
606 sel_method->is_protected() ? "protected " : "",
607 sel_method->is_private() ? "private " : "",
608 sel_method->external_name(),
609 (same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),
610 (same_module) ? "" : "; ",
611 (same_module) ? "" : sel_klass->class_in_module_of_loader()
612 );
613
614 // For private access see if there was a problem with nest host
615 // resolution, and if so report that as part of the message.
616 if (sel_method->is_private()) {
617 print_nest_host_error_on(&ss, ref_klass, sel_klass, THREAD);
618 }
619
620 Exceptions::fthrow(THREAD_AND_LOCATION,
621 vmSymbols::java_lang_IllegalAccessError(),
622 "%s",
623 ss.as_string()
624 );
625 return;
626 }
627 }
628
629 Method* LinkResolver::resolve_method_statically(Bytecodes::Code code,
630 const constantPoolHandle& pool, int index, TRAPS) {
631 // This method is used only
632 // (1) in C2 from InlineTree::ok_to_inline (via ciMethod::check_call),
633 // and
634 // (2) in Bytecode_invoke::static_target
934 resolved_klass,
935 sel_klass,
936 fd.access_flags(),
937 true, false, CHECK);
938 // Any existing exceptions that may have been thrown, for example LinkageErrors
939 // from nest-host resolution, have been allowed to propagate.
940 if (!can_access) {
941 bool same_module = (sel_klass->module() == ref_klass->module());
942 ResourceMark rm(THREAD);
943 stringStream ss;
944 ss.print("class %s tried to access %s%sfield %s.%s (%s%s%s)",
945 ref_klass->external_name(),
946 fd.is_protected() ? "protected " : "",
947 fd.is_private() ? "private " : "",
948 sel_klass->external_name(),
949 fd.name()->as_C_string(),
950 (same_module) ? ref_klass->joint_in_module_of_loader(sel_klass) : ref_klass->class_in_module_of_loader(),
951 (same_module) ? "" : "; ",
952 (same_module) ? "" : sel_klass->class_in_module_of_loader()
953 );
954 // For private access see if there was a problem with nest host
955 // resolution, and if so report that as part of the message.
956 if (fd.is_private()) {
957 print_nest_host_error_on(&ss, ref_klass, sel_klass, THREAD);
958 }
959 Exceptions::fthrow(THREAD_AND_LOCATION,
960 vmSymbols::java_lang_IllegalAccessError(),
961 "%s",
962 ss.as_string()
963 );
964 return;
965 }
966 }
967
968 void LinkResolver::resolve_field_access(fieldDescriptor& fd, const constantPoolHandle& pool, int index, const methodHandle& method, Bytecodes::Code byte, TRAPS) {
969 LinkInfo link_info(pool, index, method, CHECK);
970 resolve_field(fd, link_info, byte, true, CHECK);
971 }
972
973 void LinkResolver::resolve_field(fieldDescriptor& fd,
974 const LinkInfo& link_info,
|