Java Virtual Machine Specification Section 5.4.3 Resolution states:
"In the case of failed resolution of an invokedynamic instruction, the bootstrap
method is not re-executed on subsequent resolution attempts."
The attached example demonstrates a failure to capture the resolution result when the BSM has thrown an exception during execution of the BSM, thus failing to create a CallSite object. Upon reexecution of the same invokedynamic bytecode, the BSM is invoked a second time even though the first resolution failed, which according to Section 5.4.3 it should not be.
The following commands reproduces the issue:
% javac --add-modules java.base --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED BSMCalledTwice.java
Note: BSMCalledTwice.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
% java --add-modules java.base --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED BSMCalledTwice
%java TestC
Caught Error:
call site initialization exception
java.lang.BootstrapMethodError: call site initialization exception
at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:384)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:250)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:240)
at TestC.main(Unknown Source)
Caused by: java.lang.invoke.StringConcatException: Mismatched number of concat constants: recipe wants 0 constants, but only 1 are passed
at java.base/java.lang.invoke.StringConcatFactory.doStringConcat(StringConcatFactory.java:597)
at java.base/java.lang.invoke.StringConcatFactory.makeConcatWithConstants(StringConcatFactory.java:547)
at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:327)
... 3 more
Caught Error:
call site initialization exception
java.lang.BootstrapMethodError: call site initialization exception
at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:384)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:250)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:240)
at TestC.main(Unknown Source)
Caused by: java.lang.invoke.StringConcatException: Mismatched number of concat constants: recipe wants 0 constants, but only 1 are passed
at java.base/java.lang.invoke.StringConcatFactory.doStringConcat(StringConcatFactory.java:597)
at java.base/java.lang.invoke.StringConcatFactory.makeConcatWithConstants(StringConcatFactory.java:547)
at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:327)
... 3 more
"In the case of failed resolution of an invokedynamic instruction, the bootstrap
method is not re-executed on subsequent resolution attempts."
The attached example demonstrates a failure to capture the resolution result when the BSM has thrown an exception during execution of the BSM, thus failing to create a CallSite object. Upon reexecution of the same invokedynamic bytecode, the BSM is invoked a second time even though the first resolution failed, which according to Section 5.4.3 it should not be.
The following commands reproduces the issue:
% javac --add-modules java.base --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED BSMCalledTwice.java
Note: BSMCalledTwice.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
% java --add-modules java.base --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED BSMCalledTwice
%java TestC
Caught Error:
call site initialization exception
java.lang.BootstrapMethodError: call site initialization exception
at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:384)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:250)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:240)
at TestC.main(Unknown Source)
Caused by: java.lang.invoke.StringConcatException: Mismatched number of concat constants: recipe wants 0 constants, but only 1 are passed
at java.base/java.lang.invoke.StringConcatFactory.doStringConcat(StringConcatFactory.java:597)
at java.base/java.lang.invoke.StringConcatFactory.makeConcatWithConstants(StringConcatFactory.java:547)
at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:327)
... 3 more
Caught Error:
call site initialization exception
java.lang.BootstrapMethodError: call site initialization exception
at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:384)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:250)
at java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:240)
at TestC.main(Unknown Source)
Caused by: java.lang.invoke.StringConcatException: Mismatched number of concat constants: recipe wants 0 constants, but only 1 are passed
at java.base/java.lang.invoke.StringConcatFactory.doStringConcat(StringConcatFactory.java:597)
at java.base/java.lang.invoke.StringConcatFactory.makeConcatWithConstants(StringConcatFactory.java:547)
at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:327)
... 3 more
- duplicates
-
JDK-8174954 Parameter target type is allowed access after a module read edge or a package export has occurred after failed resolution
-
- Resolved
-