Hi,

Please review:

  
http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8166974-indy-errors-not-wrapped-jdk/webrev/
  
http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8166974-indy-errors-not-wrapped-hotspot/webrev/

The JMV spec was recently updated to state the following in the Linkage 
Exceptions section of the invokedynamic instruction:

https://bugs.openjdk.java.net/browse/JDK-8164693

"If resolution of the symbolic reference to the call site specifier throws an 
exception E, the invokedynamic instruction
<add>throws E if the type of E is Error or a subclass, else it</add>
throws a BootstrapMethodError that wraps E."

"Otherwise, during the continuing resolution of the call site specifier, if 
invocation of the bootstrap method completes abruptly (§2.6.5) because of a 
throw of exception E, the invokedynamic instruction
<add>throws E if the type of E is Error or a subclass, else it</add>
throws a BootstrapMethodError that wraps E.”

Namely if linkage fails due to the throwing of an Error or subclass then that 
Error is re-thrown by the indy. All other types of exception that may be thrown 
are wrapped in BootstrapMethodError that is then thrown. This means that errors 
such as ThreadDeath or OutOfMemoryError will pass through unwrapped.

This is a behavioural change but we anticipate one that should have minimal 
impact.


This change was motivated by updates to some classes using VarHandle for which 
VarHandle method linkage unduly wrapped some errors (like ThreadDeath) in 
LinkageError. (Note the same will apply for MethodHandle invoke linkage, or 
MethodHandle/MethodType resolution in the constant pool, or for string 
concatenation which now leverages indy). VarHandle/MethodHandle linkage error 
behaviour is tracked by another issue, 
https://bugs.openjdk.java.net/browse/JDK-8163553, which should not require any 
specification change.

Thanks,
Paul.

Reply via email to