-
Notifications
You must be signed in to change notification settings - Fork 715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip parameter access check for reflect objects #2402
Conversation
@@ -580,7 +582,7 @@ public MethodHandle findSpecial(Class<?> clazz, String methodName, MethodType ty | |||
/*[MSG "K0586", "Lookup class ({0}) must be the same as or subclass of the current class ({1})"]*/ | |||
throw new IllegalAccessException(com.ibm.oti.util.Msg.getString("K0586", accessClass, handleDefc)); //$NON-NLS-1$ | |||
} | |||
checkAccess(handle); | |||
checkAccess(handle, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't MethodHandle lookups also get the implied read access?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
j.l.MethodHandles.findSpecial()
performs checkSpecialAccess(specialToken)
which ensures PRIVATE access
or accessClass equals callerClass
hence checkClassModuleVisibility() Objects.equals(accessModule, targetModule)
is true regardless of reflectiveAccess
. In this case specifying true
or false
in this checkAccess(handle, reflectiveAccess)
won't make a difference.
On the other hand, not all MethodHandle lookups
have the implied read access, for example, j.l.MethodHandles.findVirtual()
in following code snippet doesn't imply read access to unnamed
modules:
Class<?> lookupTarget = Class.forName("class.to.be.loaded.from.classpath");
MethodHandles.lookup().findVirtual(lookupTarget, "testFindSpecial", MethodType.methodType(void.class));
This should throw java.lang.IllegalAccessException
: com.greetings
no access to: atestse.java_lang_invoke
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tajila does comment above address your concern?
@JasonFengJ9 - given the above and this being marked as a blocker for the OpenJ9 builds, do we have an ETA for this? |
@JasonFengJ9 - any update? this is blocking RC2 |
Still investigating to figure out a way to match RI behaviours when fixing the issue reported. |
The behaviour difference between
In the scenario reported, this code was invoked from module Following a simplified testcase can reproduce the problem:
A
Another
Note this
However I haven't find any specification to support such behaviours yet. |
Introduced a boolean flag to indicate that MethodType parameters should be skipped for access checking; Skip parameter access check for reflect objects; Adopted this extra parameter in other APIs. Signed-off-by: Jason Feng <fengj@ca.ibm.com>
e9d8c1c
to
7efe916
Compare
@tajila please have another look. Will add automated tests a bit later. |
@gacholio could you review? |
jenkins test sanity xlinux jdk8 |
@JasonFengJ9 Are you planning to add an FV test for this case? |
@DanHeidinga yes, it's in progress. |
Skip parameter access check for reflect objects
Introduced a boolean flag to indicate that MethodType parameters should be skipped for access checking;
Skip parameter access check for reflect objects;
Adopted this extra parameter in other APIs.
Manually verified that this PR fixes #2355
Peer reviewer: @tajila
Senior reviewer: @gacholio
Signed-off-by: Jason Feng fengj@ca.ibm.com