< prev index next >

src/hotspot/share/prims/methodHandles.cpp

Print this page




 728   if ((flags & ALL_KINDS) == IS_METHOD &&
 729       (defc == SystemDictionary::MethodHandle_klass() || defc == SystemDictionary::VarHandle_klass()) &&
 730       (ref_kind == JVM_REF_invokeVirtual ||
 731        ref_kind == JVM_REF_invokeSpecial ||
 732        // static invocation mode is required for _linkToVirtual, etc.:
 733        ref_kind == JVM_REF_invokeStatic)) {
 734     vmIntrinsics::ID iid = signature_polymorphic_name_id(name);
 735     if (iid != vmIntrinsics::_none &&
 736         ((ref_kind == JVM_REF_invokeStatic) == is_signature_polymorphic_static(iid))) {
 737       // Virtual methods invoke and invokeExact, plus internal invokers like _invokeBasic.
 738       // For a static reference it could an internal linkage routine like _linkToVirtual, etc.
 739       mh_invoke_id = iid;
 740     }
 741   }
 742 
 743   // convert the external string or reflective type to an internal signature
 744   TempNewSymbol type = lookup_signature(type_str(), (mh_invoke_id != vmIntrinsics::_none), CHECK_(empty));
 745   if (type == NULL)  return empty;  // no such signature exists in the VM
 746 
 747   LinkInfo::AccessCheck access_check = caller != NULL ?
 748                                               LinkInfo::needs_access_check :
 749                                               LinkInfo::skip_access_check;
 750 
 751   // Time to do the lookup.
 752   switch (flags & ALL_KINDS) {
 753   case IS_METHOD:
 754     {
 755       CallInfo result;
 756       LinkInfo link_info(defc, name, type, caller, access_check);
 757       {
 758         assert(!HAS_PENDING_EXCEPTION, "");
 759         if (ref_kind == JVM_REF_invokeStatic) {
 760           LinkResolver::resolve_static_call(result,
 761                         link_info, false, THREAD);
 762         } else if (ref_kind == JVM_REF_invokeInterface) {
 763           LinkResolver::resolve_interface_call(result, Handle(), defc,
 764                         link_info, false, THREAD);
 765         } else if (mh_invoke_id != vmIntrinsics::_none) {
 766           assert(!is_signature_polymorphic_static(mh_invoke_id), "");
 767           LinkResolver::resolve_handle_call(result, link_info, THREAD);
 768         } else if (ref_kind == JVM_REF_invokeSpecial) {
 769           LinkResolver::resolve_special_call(result, Handle(),


 802         } else {
 803           break;                // will throw after end of switch
 804         }
 805         if (HAS_PENDING_EXCEPTION) {
 806           if (speculative_resolve) {
 807             CLEAR_PENDING_EXCEPTION;
 808           }
 809           return empty;
 810         }
 811       }
 812       assert(result.is_statically_bound(), "");
 813       result.set_resolved_method_name(CHECK_(empty));
 814       oop mname2 = init_method_MemberName(mname, result, THREAD);
 815       return Handle(THREAD, mname2);
 816     }
 817   case IS_FIELD:
 818     {
 819       fieldDescriptor result; // find_field initializes fd if found
 820       {
 821         assert(!HAS_PENDING_EXCEPTION, "");
 822         LinkInfo link_info(defc, name, type, caller, LinkInfo::skip_access_check);
 823         LinkResolver::resolve_field(result, link_info, Bytecodes::_nop, false, THREAD);
 824         if (HAS_PENDING_EXCEPTION) {
 825           if (speculative_resolve) {
 826             CLEAR_PENDING_EXCEPTION;
 827           }
 828           return empty;
 829         }
 830       }
 831       oop mname2 = init_field_MemberName(mname, result, ref_kind_is_setter(ref_kind));
 832       return Handle(THREAD, mname2);
 833     }
 834   default:
 835     THROW_MSG_(vmSymbols::java_lang_InternalError(), "unrecognized MemberName format", empty);
 836   }
 837 
 838   return empty;
 839 }
 840 
 841 // Conversely, a member name which is only initialized from JVM internals
 842 // may have null defc, name, and type fields.




 728   if ((flags & ALL_KINDS) == IS_METHOD &&
 729       (defc == SystemDictionary::MethodHandle_klass() || defc == SystemDictionary::VarHandle_klass()) &&
 730       (ref_kind == JVM_REF_invokeVirtual ||
 731        ref_kind == JVM_REF_invokeSpecial ||
 732        // static invocation mode is required for _linkToVirtual, etc.:
 733        ref_kind == JVM_REF_invokeStatic)) {
 734     vmIntrinsics::ID iid = signature_polymorphic_name_id(name);
 735     if (iid != vmIntrinsics::_none &&
 736         ((ref_kind == JVM_REF_invokeStatic) == is_signature_polymorphic_static(iid))) {
 737       // Virtual methods invoke and invokeExact, plus internal invokers like _invokeBasic.
 738       // For a static reference it could an internal linkage routine like _linkToVirtual, etc.
 739       mh_invoke_id = iid;
 740     }
 741   }
 742 
 743   // convert the external string or reflective type to an internal signature
 744   TempNewSymbol type = lookup_signature(type_str(), (mh_invoke_id != vmIntrinsics::_none), CHECK_(empty));
 745   if (type == NULL)  return empty;  // no such signature exists in the VM
 746 
 747   LinkInfo::AccessCheck access_check = caller != NULL ?
 748                                               LinkInfo::AccessCheck::needs_access_check :
 749                                               LinkInfo::AccessCheck::skip_access_check;
 750 
 751   // Time to do the lookup.
 752   switch (flags & ALL_KINDS) {
 753   case IS_METHOD:
 754     {
 755       CallInfo result;
 756       LinkInfo link_info(defc, name, type, caller, access_check);
 757       {
 758         assert(!HAS_PENDING_EXCEPTION, "");
 759         if (ref_kind == JVM_REF_invokeStatic) {
 760           LinkResolver::resolve_static_call(result,
 761                         link_info, false, THREAD);
 762         } else if (ref_kind == JVM_REF_invokeInterface) {
 763           LinkResolver::resolve_interface_call(result, Handle(), defc,
 764                         link_info, false, THREAD);
 765         } else if (mh_invoke_id != vmIntrinsics::_none) {
 766           assert(!is_signature_polymorphic_static(mh_invoke_id), "");
 767           LinkResolver::resolve_handle_call(result, link_info, THREAD);
 768         } else if (ref_kind == JVM_REF_invokeSpecial) {
 769           LinkResolver::resolve_special_call(result, Handle(),


 802         } else {
 803           break;                // will throw after end of switch
 804         }
 805         if (HAS_PENDING_EXCEPTION) {
 806           if (speculative_resolve) {
 807             CLEAR_PENDING_EXCEPTION;
 808           }
 809           return empty;
 810         }
 811       }
 812       assert(result.is_statically_bound(), "");
 813       result.set_resolved_method_name(CHECK_(empty));
 814       oop mname2 = init_method_MemberName(mname, result, THREAD);
 815       return Handle(THREAD, mname2);
 816     }
 817   case IS_FIELD:
 818     {
 819       fieldDescriptor result; // find_field initializes fd if found
 820       {
 821         assert(!HAS_PENDING_EXCEPTION, "");
 822         LinkInfo link_info(defc, name, type, caller, LinkInfo::AccessCheck::skip_access_check);
 823         LinkResolver::resolve_field(result, link_info, Bytecodes::_nop, false, THREAD);
 824         if (HAS_PENDING_EXCEPTION) {
 825           if (speculative_resolve) {
 826             CLEAR_PENDING_EXCEPTION;
 827           }
 828           return empty;
 829         }
 830       }
 831       oop mname2 = init_field_MemberName(mname, result, ref_kind_is_setter(ref_kind));
 832       return Handle(THREAD, mname2);
 833     }
 834   default:
 835     THROW_MSG_(vmSymbols::java_lang_InternalError(), "unrecognized MemberName format", empty);
 836   }
 837 
 838   return empty;
 839 }
 840 
 841 // Conversely, a member name which is only initialized from JVM internals
 842 // may have null defc, name, and type fields.


< prev index next >