1673 // Otherwise wrap the exception in a BootstrapMethodError 1674 if (TraceMethodHandles) { 1675 tty->print_cr("invokedynamic throws BSME for " INTPTR_FORMAT, p2i((void *)PENDING_EXCEPTION)); 1676 PENDING_EXCEPTION->print(); 1677 } 1678 Handle nested_exception(THREAD, PENDING_EXCEPTION); 1679 CLEAR_PENDING_EXCEPTION; 1680 THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception) 1681 } 1682 } 1683 1684 void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { 1685 Symbol* method_name = pool->name_ref_at(index); 1686 Symbol* method_signature = pool->signature_ref_at(index); 1687 Klass* current_klass = pool->pool_holder(); 1688 1689 // Resolve the bootstrap specifier (BSM + optional arguments). 1690 Handle bootstrap_specifier; 1691 // Check if CallSite has been bound already: 1692 ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(index); 1693 if (cpce->is_f1_null()) { 1694 int pool_index = cpce->constant_pool_index(); 1695 oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, THREAD); 1696 wrap_invokedynamic_exception(CHECK); 1697 assert(bsm_info != NULL, ""); 1698 // FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic. 1699 bootstrap_specifier = Handle(THREAD, bsm_info); 1700 } 1701 if (!cpce->is_f1_null()) { 1702 methodHandle method( THREAD, cpce->f1_as_method()); 1703 Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); 1704 Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); 1705 result.set_handle(method, appendix, method_type, THREAD); 1706 wrap_invokedynamic_exception(CHECK); 1707 return; 1708 } 1709 1710 if (TraceMethodHandles) { 1711 ResourceMark rm(THREAD); 1712 tty->print_cr("resolve_invokedynamic #%d %s %s in %s", 1713 ConstantPool::decode_invokedynamic_index(index), 1714 method_name->as_C_string(), method_signature->as_C_string(), 1715 current_klass->name()->as_C_string()); 1716 tty->print(" BSM info: "); bootstrap_specifier->print(); 1717 } 1718 1719 resolve_dynamic_call(result, bootstrap_specifier, method_name, method_signature, current_klass, CHECK); 1720 } 1721 1722 void LinkResolver::resolve_dynamic_call(CallInfo& result, 1723 Handle bootstrap_specifier, 1724 Symbol* method_name, Symbol* method_signature, 1725 Klass* current_klass, 1726 TRAPS) { 1727 // JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...) 1728 // The appendix argument is likely to be a freshly-created CallSite. 1729 Handle resolved_appendix; 1730 Handle resolved_method_type; 1731 methodHandle resolved_method = 1732 SystemDictionary::find_dynamic_call_site_invoker(current_klass, 1733 bootstrap_specifier, 1734 method_name, method_signature, 1735 &resolved_appendix, 1736 &resolved_method_type, 1737 THREAD); 1738 wrap_invokedynamic_exception(CHECK); 1739 result.set_handle(resolved_method, resolved_appendix, resolved_method_type, THREAD); | 1673 // Otherwise wrap the exception in a BootstrapMethodError 1674 if (TraceMethodHandles) { 1675 tty->print_cr("invokedynamic throws BSME for " INTPTR_FORMAT, p2i((void *)PENDING_EXCEPTION)); 1676 PENDING_EXCEPTION->print(); 1677 } 1678 Handle nested_exception(THREAD, PENDING_EXCEPTION); 1679 CLEAR_PENDING_EXCEPTION; 1680 THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception) 1681 } 1682 } 1683 1684 void LinkResolver::resolve_invokedynamic(CallInfo& result, const constantPoolHandle& pool, int index, TRAPS) { 1685 Symbol* method_name = pool->name_ref_at(index); 1686 Symbol* method_signature = pool->signature_ref_at(index); 1687 Klass* current_klass = pool->pool_holder(); 1688 1689 // Resolve the bootstrap specifier (BSM + optional arguments). 1690 Handle bootstrap_specifier; 1691 // Check if CallSite has been bound already: 1692 ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(index); 1693 int pool_index = cpce->constant_pool_index(); 1694 if (pool()->tag_at(pool_index).is_invoke_dynamic_in_error()) { 1695 // Throw saved exception. 1696 ConstantPool::throw_resolution_error(pool, pool_index, CHECK); 1697 return; 1698 } 1699 1700 if (cpce->is_f1_null()) { 1701 oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, THREAD); 1702 wrap_invokedynamic_exception(CHECK); 1703 assert(bsm_info != NULL, ""); 1704 // FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic. 1705 bootstrap_specifier = Handle(THREAD, bsm_info); 1706 } 1707 if (!cpce->is_f1_null()) { 1708 methodHandle method( THREAD, cpce->f1_as_method()); 1709 Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); 1710 Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); 1711 result.set_handle(method, appendix, method_type, THREAD); 1712 wrap_invokedynamic_exception(CHECK); 1713 return; 1714 } 1715 1716 if (TraceMethodHandles) { 1717 ResourceMark rm(THREAD); 1718 tty->print_cr("resolve_invokedynamic #%d %s %s in %s", 1719 ConstantPool::decode_invokedynamic_index(index), 1720 method_name->as_C_string(), method_signature->as_C_string(), 1721 current_klass->name()->as_C_string()); 1722 tty->print(" BSM info: "); bootstrap_specifier->print(); 1723 } 1724 1725 resolve_dynamic_call(result, bootstrap_specifier, method_name, method_signature, current_klass, THREAD); 1726 if (HAS_PENDING_EXCEPTION) { 1727 if (pool()->tag_at(pool_index).is_invoke_dynamic()&& 1728 PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { 1729 // Record the exception then throw it. 1730 ConstantPool::save_and_throw_exception(pool, pool_index, pool()->tag_at(pool_index), CHECK); 1731 } else if (pool()->tag_at(pool_index).is_invoke_dynamic_in_error()) { 1732 // Throw saved exception. 1733 ConstantPool::throw_resolution_error(pool, pool_index, CHECK); 1734 } // else return the original exception. 1735 } 1736 } 1737 1738 void LinkResolver::resolve_dynamic_call(CallInfo& result, 1739 Handle bootstrap_specifier, 1740 Symbol* method_name, Symbol* method_signature, 1741 Klass* current_klass, 1742 TRAPS) { 1743 // JSR 292: this must resolve to an implicitly generated method MH.linkToCallSite(*...) 1744 // The appendix argument is likely to be a freshly-created CallSite. 1745 Handle resolved_appendix; 1746 Handle resolved_method_type; 1747 methodHandle resolved_method = 1748 SystemDictionary::find_dynamic_call_site_invoker(current_klass, 1749 bootstrap_specifier, 1750 method_name, method_signature, 1751 &resolved_appendix, 1752 &resolved_method_type, 1753 THREAD); 1754 wrap_invokedynamic_exception(CHECK); 1755 result.set_handle(resolved_method, resolved_appendix, resolved_method_type, THREAD); |