RFR(S+M) / 8022701 Accessibility checking: InvocationTargetException is thrown instead of IllegalAccessError

Remi Forax forax at univ-mlv.fr
Thu Sep 26 23:13:19 PDT 2013


On 09/27/2013 06:33 AM, John Rose wrote:
> On Sep 19, 2013, at 9:57 AM, David Chase <david.r.chase at oracle.com> wrote:
>
>> Recommended changes made:
>>
>> http://cr.openjdk.java.net/~drchase/8022701/webrev.04/
> Good; reviewed.
>
> Consider adding this tweak, which would close the loop on alternation between the fooError and fooException versions:
>
> +    static private void initCauseFrom(Error err, Exception ex) {
> +        Throwable th = ex.getCause();
> ++      if (err.getClass().isInstance(th))  throw (Error) th;
> +        err.initCause(th == null ? ex : th);
> +    }
>
> E.g., if the reason for linkage failure was originally NoSuchMethodError, but was mapped to NoSuchMethodException (which can happen in MemberName.makeAccessException) then the original NoSuchMethodError is extracted and thrown, rather than a new NoSuchMethodError which wraps the original NoSuchMethodError.

I'm late in this game but having a method initCauseFrom() that throws an 
exception (an error exactly)
seems plainly wrong to me.

>
>> Test with jtreg (for pass and for induced failure) on MacOS,
>> not sure what additional other testing is desired since it is entirely in the libraries.
> Your test case is enough.
>
>> I included code to handle the case of a broken field-referencing methodhandle,
>> but did not test it because there's no syntax for these in Java, nor is their creation
>> well-documented.
> That's fine.  Ship it, preferably with the tweak above.
>
> — John

Rémi



More information about the mlvm-dev mailing list