RFR(S) / guidance, 8022701 Accessibility checking: InvocationTargetException is thrown instead of IllegalAccessError
david.r.chase at oracle.com
Fri Sep 6 14:18:00 UTC 2013
bug: The bug report is not correct, but there is nonetheless a related underlying bug where IllegalAccessError fails to be thrown.
Question #1, is this a corelibs bug? It was filed against compiler, but the fix is in the jdk classes, but it is MethodHandle code.
Question #2, what's the best way to write a jtreg test suite that requires incompatible class files, that could not result from a single javac compilation?
Question #3, the message(s) attached to the exception are not the same in all cases:
a. IllegalAccessError's been caught java.lang.IllegalAccessError: member is private: MethodSupplier.m()void/invokeVirtual, from MethodInvoker
b. IllegalAccessError's been caught java.lang.IllegalAccessError: tried to access method MethodSupplier.m()V from class MethodInvoker
c. IllegalAccessError's been caught java.lang.IllegalAccessError:
d. IllegalAccessError's been caught java.lang.IllegalAccessError: tried to access method MethodSupplier.m()V from class MethodInvoker
The difference between a. and c. above (and these are the two that change under this fix, the code the execution definitely intersects at the fix) is:
a = Class.forName("MethodInvoker").getMethod("invoke").invoke(null);
c = MethodInvoker.invoke();
yet one has the message copied from the underlying IllegalAccessException (not IAError) and the other does not.
More information about the core-libs-dev