RFR: 8177086: java.lang.reflect.AccessibleObject::canAccess should share access cache with internal method ::checkAccess

Mandy Chung mandy.chung at oracle.com
Mon Mar 20 17:46:16 UTC 2017

> On Mar 19, 2017, at 3:42 PM, Peter Levart <peter.levart at gmail.com> wrote:
> Hi Alan,
>> When integrating with the cache came up on jigsaw-dev a few work ago then I think Mandy wanted to defer to it to JDK 10. However since canAccess is new then having is be more efficient might be good, it just mightn't be a P1/P2 for RDP2. Can you re-base the patch against jake as has changed this code and then maybe we can figure out whether to pull it into jake?

Right I considered the optimization with the cache but deferred it as a follow-up issue.

> No problem. Here it is (against tip of jake/jdk):
> http://cr.openjdk.java.net/~plevart/jdk9-jake/AccessibleObject.canAccess_caching/webrev.02/

This patch looks good and nice speedup.  It may be good to pull in to jake for integration into jdk9 that will cover more testing.

line 339-342: formatting nit: parameters in the signature consistent with the convention used in this file (see verifyMemberAccess method for example).

> This patch changes a little when the stacktrace requested by sun.reflect.debugModuleAccessChecks system property is printed. In original code it is printed when the access (invocation, get/set) itself fails as well as when AccessibleObject.canAccess() returns false. Is that what was intended? Patched code only prints when the actual access attempt fails and not when canAccess() returns false.

Good catch.  canAccess is a test method that does not change the access and no t printing the stack trace sounds right to me.

Thanks for this fix.

More information about the jigsaw-dev mailing list