JDK-7049415 : Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
Type:Bug
Component:hotspot
Sub-Component:compiler
Affected Version:7
Priority:P3
Status:Resolved
Resolution:Fixed
OS:generic
CPU:generic
Submitted:2011-05-28
Updated:2015-06-15
Resolved:2011-06-04
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
SUGGESTED FIX
From: John Rose <###@###.###>
Date: June 1, 2011 11:44:29 AM PDT
To: hotspot compiler <###@###.###>
Subject: review request (URGENT): 7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
Low-level fix to ensure wrapping of early linkage errors in bootstrap method errors, for invokedynamic corner cases.
7049415: Failure of resolution of sym.reference to the c.s.s. should be wrapped in BootstrapMethodError
JVM Summary: Delegate invokedynamic linkage errors to MethodHandleNatives.raiseException.
JDK Summary: Wrap invokedynamic linkage errors in BootstrapMethodError, as needed.
http://cr.openjdk.java.net/~jrose/7049415/webrev.jvm.00
http://cr.openjdk.java.net/~jrose/7049415/webrev.jdk.00
These changes can integrate in any order. To fix the bug, both must be integrated.
Test case attached. All paths have been exercised.
-- John
<Test 7049415.java>
01-06-2011
EVALUATION
A corner case of a corner case, but covered by the JCK: If an invokedynamic instruction fails to link because a constant pool reference fails to resolve before the BSM is invoked, the JVM can fail to wrap the LinkageError inside a BootstrapMethodError (which is also a LinkageError).
Thus, users who (a) have broken indy instructions and (b) are catching BSME (but not LE) will be surprised by a lack of spec. compliance.
The fix is fairly simple: Cut into the JVM routine which resolves an invokedynamic instruction, and cause it to verify any LinkageError is in fact a BSME. If a stray LE is found, wrap it. We have to call up to Java to get the wrapping done. Ungraceful, but it works.