RFR 8166974: invokedynamic implementation should not wrap Errors

Stuart Marks stuart.marks at oracle.com
Tue Oct 18 00:52:10 UTC 2016

On 10/17/16 5:16 PM, Paul Sandoz wrote:
>> On 17 Oct 2016, at 16:36, John Rose <john.r.rose at oracle.com> wrote:
>> On Oct 17, 2016, at 3:38 PM, Paul Sandoz <paul.sandoz at oracle.com> wrote:
>>>> On 17 Oct 2016, at 15:01, Stuart Marks <stuart.marks at oracle.com> wrote:
>>>> Usually I wrinkle my nose at a throw that's caught by a catch clause later on, but in this case it's not obvious what would be better. Maybe a comment is warranted?
>>> In addition to the
>>> // See the "Linking Exceptions" section for the invokedynamic
>>> // instruction in JVMS 6.5.
>>> I can add something like:
>>> // Throws a runtime exception defining the cause that is then later wrapped in BootstrapMethodError
>> I agree.  Maybe s/later/in the "catch (Throwable ex)" a few lines below"/, to be more specific.
> Thanks, updated in place.

The revised comment is a bit more verbose than my taste, but it's fine as it is. 
The main point is to alert the reader that something unusual is going on.

[from John]
>> I think the throw-to-catch is good here, unusually, because it funnels all BSME-wrapped
>> exceptions through one point.  That may make somebody's day easier when placing breakpoints.

Agreed. This approach is indeed unusual, but I think the alternatives are worse: 
either the BSME wrapping can be replicated at the point of the throw, or it 
could be refactored into a common method. Either seems like a step in the wrong 
direction. Once you figure out this code, it isn't so bad; it's just unusual.


More information about the core-libs-dev mailing list