diff -r 91a1be057e0a -r 81bed6c76a89 src/share/vm/interpreter/linkResolver.cpp --- a/src/share/vm/interpreter/linkResolver.cpp Thu Jun 04 23:11:44 2015 -0700 +++ b/src/share/vm/interpreter/linkResolver.cpp Thu May 07 15:05:46 2015 +0200 @@ -1592,6 +1592,26 @@ result.set_handle(resolved_method, resolved_appendix, resolved_method_type, CHECK); } +static void wrap_invokedynamic_exception(TRAPS) { + if (HAS_PENDING_EXCEPTION) { + if (TraceMethodHandles) { + tty->print_cr("invokedynamic throws BSME for " INTPTR_FORMAT, p2i((void *)PENDING_EXCEPTION)); + PENDING_EXCEPTION->print(); + } + if (PENDING_EXCEPTION->is_a(SystemDictionary::BootstrapMethodError_klass())) { + // throw these guys, since they are already wrapped + return; + } + if (!PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { + // intercept only LinkageErrors which might have failed to wrap + return; + } + // See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS. + Handle nested_exception(THREAD, PENDING_EXCEPTION); + CLEAR_PENDING_EXCEPTION; + THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception) + } +} void LinkResolver::resolve_invokedynamic(CallInfo& result, constantPoolHandle pool, int index, TRAPS) { assert(EnableInvokeDynamic, ""); @@ -1607,7 +1627,8 @@ ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(index); if (cpce->is_f1_null()) { int pool_index = cpce->constant_pool_index(); - oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, CHECK); + oop bsm_info = pool->resolve_bootstrap_specifier_at(pool_index, THREAD); + wrap_invokedynamic_exception(CHECK); assert(bsm_info != NULL, ""); // FIXME: Cache this once per BootstrapMethods entry, not once per CONSTANT_InvokeDynamic. bootstrap_specifier = Handle(THREAD, bsm_info); @@ -1616,7 +1637,8 @@ methodHandle method( THREAD, cpce->f1_as_method()); Handle appendix( THREAD, cpce->appendix_if_resolved(pool)); Handle method_type(THREAD, cpce->method_type_if_resolved(pool)); - result.set_handle(method, appendix, method_type, CHECK); + result.set_handle(method, appendix, method_type, THREAD); + wrap_invokedynamic_exception(CHECK); return; } @@ -1647,25 +1669,9 @@ &resolved_appendix, &resolved_method_type, THREAD); - if (HAS_PENDING_EXCEPTION) { - if (TraceMethodHandles) { - tty->print_cr("invokedynamic throws BSME for " INTPTR_FORMAT, p2i((void *)PENDING_EXCEPTION)); - PENDING_EXCEPTION->print(); - } - if (PENDING_EXCEPTION->is_a(SystemDictionary::BootstrapMethodError_klass())) { - // throw these guys, since they are already wrapped - return; - } - if (!PENDING_EXCEPTION->is_a(SystemDictionary::LinkageError_klass())) { - // intercept only LinkageErrors which might have failed to wrap - return; - } - // See the "Linking Exceptions" section for the invokedynamic instruction in the JVMS. - Handle nested_exception(THREAD, PENDING_EXCEPTION); - CLEAR_PENDING_EXCEPTION; - THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception) - } - result.set_handle(resolved_method, resolved_appendix, resolved_method_type, CHECK); + wrap_invokedynamic_exception(CHECK); + result.set_handle(resolved_method, resolved_appendix, resolved_method_type, THREAD); + wrap_invokedynamic_exception(CHECK); } //------------------------------------------------------------------------------------------------------------------------