RFR 8166974: invokedynamic implementation should not wrap Errors

David Holmes david.holmes at oracle.com
Mon Oct 17 22:33:40 UTC 2016


Hi Paul,

Looking at hotspot changes only ...

On 15/10/2016 8:08 AM, Paul Sandoz wrote:
> 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/

src/share/vm/interpreter/linkResolver.cpp

Changes seem fine, but the existing tracing code - which was already 
somewhat incorrect - now appears even more incorrect. It either needs to 
be moved to after the return for the Error case - so that we really are 
going to throw BSME - or else two different trace statements are needed.

--

test/runtime/invokedynamic/BootstrapMethodErrorTest.java

  2  * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights 
reserved.

Need comma after 2016.

Otherwise all good.

Thanks,
David

> 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.
>


More information about the core-libs-dev mailing list