-
Notifications
You must be signed in to change notification settings - Fork 214
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
8280377: MethodHandleProxies does not correctly invoke default methods with varags #2235
Conversation
👋 Welcome back Delawen! A progress list of the required criteria for merging this PR into |
This backport pull request has now been updated with issue from the original commit. |
|
/approval JDK-8280377 request Fix Request |
Hi @Delawen, I think this is a larger change that should get some more testing than just checking that is fixes the issue. |
I tested with the
With the regular Java 17 installed on my Debian, I get the expected error pre-fix (I also tested with a local build of latest master at the time, but as I built with the fix, I cannot provide right now the output for that):
After fixing it, I get the correct answer:
|
@GoeLin I am going to test other things with my local build with the fix, like running other Java apps. Any suggestions on what should I try to make sure it works, besides the different |
The commit contains a test for the different ways of calling a method with varargs: https://github.com/openjdk/jdk17u-dev/pull/2235/files#diff-41008904ed7aa596f5de5930e082a8cf6b239603883818fa940bb04ff511455aR65-R68 But I understand this may be a "too simple" example. |
@mlchung You did the original commit for this fix. Can you give me some ideas on how to properly test this backport and make sure I'm not breaking anything else? // cc @AlanBateman @DasBrain @liach as you were also involved on the original PR |
I did not read through the entire patch - @mlchung did comment on the bug report back then:
|
The backport looks good to me. This is the same fix for JDK-8280377 and includes the regression test. Tier1-3 tests including this new regression test should provide adequate verification. |
The alternative backport fix is for JDK versions before 16 when Proxy.invokeDefault was not available, right? |
Yes. |
@@ -262,33 +261,6 @@ public static Object invokeDefault(Object proxy, Method method, Object... args) | |||
throws Throwable { | |||
Objects.requireNonNull(proxy); | |||
Objects.requireNonNull(method); | |||
|
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.
This removed piece of code is moved to Proxy.invokeDefault
(which is now called at the end of this removed code). The code moved is mostly the same, except it checks if the caller object is null. If it is null, then it won't execute anything.
// unwrap and throw the exception thrown by the default method | ||
throw e.getCause(); | ||
} | ||
return Proxy.invokeDefault(proxy, method, args, Reflection.getCallerClass()); |
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.
This is where we call the previously removed piece of code.
@@ -202,7 +202,8 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl | |||
if (isObjectMethod(method)) | |||
return callObjectMethod(proxy, method, args); | |||
if (isDefaultMethod(method)) { | |||
return callDefaultMethod(defaultMethodMap, proxy, intfc, method, args); | |||
// no additional access check is performed | |||
return JLRA.invokeDefault(proxy, method, args, null); |
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.
As defined at the end of the file, JavaLangReflectAccess JLRA = SharedSecrets.getJavaLangReflectAccess();
which is an interface implemented by ReflectAccess.java
(modified below)
@@ -320,37 +321,5 @@ private static boolean isDefaultMethod(Method m) { | |||
return !Modifier.isAbstract(m.getModifiers()); | |||
} | |||
|
|||
private static boolean hasDefaultMethods(Class<?> intfc) { |
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.
This piece of code is removed because it is no longer used. Now, instead of calling callDefaultMethod(...)
, we are calling Proxy.invokeDefault(...)
which is created on this same PR.
* @throws IllegalAccessException if the proxy interface is inaccessible to the caller | ||
* if caller is non-null | ||
*/ | ||
static Object invokeDefault(Object proxy, Method method, Object[] args, Class<?> caller) |
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.
This is the piece of code that will now unify calling methods both from MethodHandleProxies
(where this code is copied from) and ReflectAccess
, which was using a different way of calling methods.
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.
OK, I see now. Thanks for the explanation.
/integrate |
Although I miss the bot saying something |
Is that what you needed, bot? |
Hi @Delawen, did you run some tests as e.g. proposed here? |
@Delawen This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 111 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@theRealAph) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
To be completely honest, I am having issues running tier2+ tests on my laptop, I am looking for an external infra to run them. |
@smlambert is using this PR branch for polishing the Trestle testing pipeline. The results are here: adoptium/aqa-tests#5137 (comment) Not all architectures pass, but (at least right now) not because of this PR, but because misconfigurations. // cc @GoeLin |
Do we need more testing here? |
I don't think we do. We have positive tier 1-3 results and the regression test. It fixes a real bug. Patch is reviewed, even though it's clean. |
/approve yes |
@jerboaa |
/approval JDK-8280377 request Fix Request |
/integrate |
/sponsor |
Going to push as commit 5ecac7a.
Your commit was automatically rebased without conflicts. |
This is a backport of https://bugs.openjdk.org/browse/JDK-8280377 MethodHandleProxies does not correctly invoke default methods with varags
I applied the same fix that was applied to version 19 in openjdk/jdk@a183bfb
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk17u-dev.git pull/2235/head:pull/2235
$ git checkout pull/2235
Update a local copy of the PR:
$ git checkout pull/2235
$ git pull https://git.openjdk.org/jdk17u-dev.git pull/2235/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2235
View PR using the GUI difftool:
$ git pr show -t 2235
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk17u-dev/pull/2235.diff
Webrev
Link to Webrev Comment