92 set_common(resolved_klass, selected_klass, resolved_method, selected_method, kind, vtable_index, CHECK); |
92 set_common(resolved_klass, selected_klass, resolved_method, selected_method, kind, vtable_index, CHECK); |
93 assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call"); |
93 assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call"); |
94 } |
94 } |
95 |
95 |
96 void CallInfo::set_handle(const methodHandle& resolved_method, |
96 void CallInfo::set_handle(const methodHandle& resolved_method, |
97 Handle resolved_appendix, |
97 Handle resolved_appendix, TRAPS) { |
98 Handle resolved_method_type, TRAPS) { |
98 set_handle(SystemDictionary::MethodHandle_klass(), resolved_method, resolved_appendix, CHECK); |
99 set_handle(SystemDictionary::MethodHandle_klass(), resolved_method, resolved_appendix, resolved_method_type, CHECK); |
|
100 } |
99 } |
101 |
100 |
102 void CallInfo::set_handle(Klass* resolved_klass, |
101 void CallInfo::set_handle(Klass* resolved_klass, |
103 const methodHandle& resolved_method, |
102 const methodHandle& resolved_method, |
104 Handle resolved_appendix, |
103 Handle resolved_appendix, TRAPS) { |
105 Handle resolved_method_type, TRAPS) { |
104 guarantee(resolved_method.not_null(), "resolved method is null"); |
106 if (resolved_method.is_null()) { |
|
107 THROW_MSG(vmSymbols::java_lang_InternalError(), "resolved method is null"); |
|
108 } |
|
109 assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic || |
105 assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic || |
110 resolved_method->is_compiled_lambda_form(), |
106 resolved_method->is_compiled_lambda_form(), |
111 "linkMethod must return one of these"); |
107 "linkMethod must return one of these"); |
112 int vtable_index = Method::nonvirtual_vtable_index; |
108 int vtable_index = Method::nonvirtual_vtable_index; |
113 assert(!resolved_method->has_vtable_index(), ""); |
109 assert(!resolved_method->has_vtable_index(), ""); |
114 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); |
110 set_common(resolved_klass, resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); |
115 _resolved_appendix = resolved_appendix; |
111 _resolved_appendix = resolved_appendix; |
116 _resolved_method_type = resolved_method_type; |
|
117 } |
112 } |
118 |
113 |
119 void CallInfo::set_common(Klass* resolved_klass, |
114 void CallInfo::set_common(Klass* resolved_klass, |
120 Klass* selected_klass, |
115 Klass* selected_klass, |
121 const methodHandle& resolved_method, |
116 const methodHandle& resolved_method, |
450 } |
445 } |
451 |
446 |
452 methodHandle LinkResolver::lookup_polymorphic_method( |
447 methodHandle LinkResolver::lookup_polymorphic_method( |
453 const LinkInfo& link_info, |
448 const LinkInfo& link_info, |
454 Handle *appendix_result_or_null, |
449 Handle *appendix_result_or_null, |
455 Handle *method_type_result, |
|
456 TRAPS) { |
450 TRAPS) { |
457 Klass* klass = link_info.resolved_klass(); |
451 Klass* klass = link_info.resolved_klass(); |
458 Symbol* name = link_info.name(); |
452 Symbol* name = link_info.name(); |
459 Symbol* full_signature = link_info.signature(); |
453 Symbol* full_signature = link_info.signature(); |
460 |
454 |
758 if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { // not found in the class hierarchy |
750 if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { // not found in the class hierarchy |
759 resolved_method = methodHandle(THREAD, lookup_method_in_interfaces(link_info)); |
751 resolved_method = methodHandle(THREAD, lookup_method_in_interfaces(link_info)); |
760 |
752 |
761 if (resolved_method.is_null()) { |
753 if (resolved_method.is_null()) { |
762 // JSR 292: see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc |
754 // JSR 292: see if this is an implicitly generated method MethodHandle.linkToVirtual(*...), etc |
763 resolved_method = lookup_polymorphic_method(link_info, (Handle*)NULL, (Handle*)NULL, THREAD); |
755 resolved_method = lookup_polymorphic_method(link_info, (Handle*)NULL, THREAD); |
764 if (HAS_PENDING_EXCEPTION) { |
756 if (HAS_PENDING_EXCEPTION) { |
765 nested_exception = Handle(THREAD, PENDING_EXCEPTION); |
757 nested_exception = Handle(THREAD, PENDING_EXCEPTION); |
766 CLEAR_PENDING_EXCEPTION; |
758 CLEAR_PENDING_EXCEPTION; |
767 } |
759 } |
768 } |
760 } |
1695 Klass* resolved_klass = link_info.resolved_klass(); |
1687 Klass* resolved_klass = link_info.resolved_klass(); |
1696 assert(resolved_klass == SystemDictionary::MethodHandle_klass() || |
1688 assert(resolved_klass == SystemDictionary::MethodHandle_klass() || |
1697 resolved_klass == SystemDictionary::VarHandle_klass(), ""); |
1689 resolved_klass == SystemDictionary::VarHandle_klass(), ""); |
1698 assert(MethodHandles::is_signature_polymorphic_name(link_info.name()), ""); |
1690 assert(MethodHandles::is_signature_polymorphic_name(link_info.name()), ""); |
1699 Handle resolved_appendix; |
1691 Handle resolved_appendix; |
1700 Handle resolved_method_type; |
1692 methodHandle resolved_method = lookup_polymorphic_method(link_info, &resolved_appendix, CHECK); |
1701 methodHandle resolved_method = lookup_polymorphic_method(link_info, |
1693 result.set_handle(resolved_klass, resolved_method, resolved_appendix, CHECK); |
1702 &resolved_appendix, &resolved_method_type, CHECK); |
|
1703 result.set_handle(resolved_klass, resolved_method, resolved_appendix, resolved_method_type, CHECK); |
|
1704 } |
1694 } |
1705 |
1695 |
1706 void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { |
1696 void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { |
1707 Symbol* method_name = pool->name_ref_at(index); |
1697 Symbol* method_name = pool->name_ref_at(index); |
1708 Symbol* method_signature = pool->signature_ref_at(index); |
1698 Symbol* method_signature = pool->signature_ref_at(index); |
1735 bootstrap_specifier = Handle(THREAD, bsm_info); |
1725 bootstrap_specifier = Handle(THREAD, bsm_info); |
1736 } |
1726 } |
1737 if (!cpce->is_f1_null()) { |
1727 if (!cpce->is_f1_null()) { |
1738 methodHandle method( THREAD, cpce->f1_as_method()); |
1728 methodHandle method( THREAD, cpce->f1_as_method()); |
1739 Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); |
1729 Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); |
1740 Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); |
1730 result.set_handle(method, appendix, THREAD); |
1741 result.set_handle(method, appendix, method_type, THREAD); |
|
1742 Exceptions::wrap_dynamic_exception(CHECK); |
1731 Exceptions::wrap_dynamic_exception(CHECK); |
1743 return; |
1732 return; |
1744 } |
1733 } |
1745 |
1734 |
1746 if (TraceMethodHandles) { |
1735 if (TraceMethodHandles) { |
1764 // Another thread got here just before we did. So, either use the method |
1753 // Another thread got here just before we did. So, either use the method |
1765 // that it resolved or throw the LinkageError exception that it threw. |
1754 // that it resolved or throw the LinkageError exception that it threw. |
1766 if (!cpce->is_f1_null()) { |
1755 if (!cpce->is_f1_null()) { |
1767 methodHandle method( THREAD, cpce->f1_as_method()); |
1756 methodHandle method( THREAD, cpce->f1_as_method()); |
1768 Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); |
1757 Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); |
1769 Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); |
1758 result.set_handle(method, appendix, THREAD); |
1770 result.set_handle(method, appendix, method_type, THREAD); |
|
1771 Exceptions::wrap_dynamic_exception(CHECK); |
1759 Exceptions::wrap_dynamic_exception(CHECK); |
1772 } else { |
1760 } else { |
1773 assert(cpce->indy_resolution_failed(), "Resolution failure flag not set"); |
1761 assert(cpce->indy_resolution_failed(), "Resolution failure flag not set"); |
1774 ConstantPool::throw_resolution_error(pool, encoded_index, CHECK); |
1762 ConstantPool::throw_resolution_error(pool, encoded_index, CHECK); |
1775 } |
1763 } |
1786 Klass* current_klass, |
1774 Klass* current_klass, |
1787 TRAPS) { |
1775 TRAPS) { |
1788 // JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...) |
1776 // JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...) |
1789 // The appendix argument is likely to be a freshly-created CallSite. |
1777 // The appendix argument is likely to be a freshly-created CallSite. |
1790 Handle resolved_appendix; |
1778 Handle resolved_appendix; |
1791 Handle resolved_method_type; |
|
1792 methodHandle resolved_method = |
1779 methodHandle resolved_method = |
1793 SystemDictionary::find_dynamic_call_site_invoker(current_klass, |
1780 SystemDictionary::find_dynamic_call_site_invoker(current_klass, |
1794 pool_index, |
1781 pool_index, |
1795 bootstrap_specifier, |
1782 bootstrap_specifier, |
1796 method_name, method_signature, |
1783 method_name, method_signature, |
1797 &resolved_appendix, |
1784 &resolved_appendix, |
1798 &resolved_method_type, |
|
1799 THREAD); |
1785 THREAD); |
1800 Exceptions::wrap_dynamic_exception(CHECK); |
1786 Exceptions::wrap_dynamic_exception(CHECK); |
1801 result.set_handle(resolved_method, resolved_appendix, resolved_method_type, THREAD); |
1787 result.set_handle(resolved_method, resolved_appendix, THREAD); |
1802 Exceptions::wrap_dynamic_exception(CHECK); |
1788 Exceptions::wrap_dynamic_exception(CHECK); |
1803 } |
1789 } |
1804 |
1790 |
1805 // Selected method is abstract. |
1791 // Selected method is abstract. |
1806 void LinkResolver::throw_abstract_method_error(const methodHandle& resolved_method, |
1792 void LinkResolver::throw_abstract_method_error(const methodHandle& resolved_method, |