-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8295102: Always load @lambda-form-invoker lines from default classlist #10639
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
8295102: Always load @lambda-form-invoker lines from default classlist #10639
Conversation
|
👋 Welcome back iklam! A progress list of the required criteria for merging this PR into |
Webrevs
|
|
Seems to me this is edging towards a scheme where the user-defined classlist is to be used to augment the default one, rather than being a complete replacement. Either the classlist should be the one-true-source for the classes to include in the archive, or else you need a way to express that you want to use it in union with the default list (to some extent), but not just (seemingly arbitrarily) decide that a special subset of classes should always be included even if missing from the classlist. |
This PR doesn't add extra classes into the archive. It just adds methods to the four Holder classes listed in the PR's description. In fact, these 4 classes (as stored in the JDK's module image) are generated at JDK build time to contain commonly used invoker methods. See GenerateLinkOptData.gmk. The intention of the However, the application's profile may use only a small number of invoker methods. As a result, if we just depend on the app's profile, the regenerated Holder classes, which are stored in the CDS archive, will be missing some invoker methods that are in JDK's module image. These missing methods cause the following problems
The default classlist (also generated by GenerateLinkOptData.gmk) contains the |
|
Sorry this was an aspect of archive generation that I was not aware of - and I still don't really grok the full picture here. |
| if (a.length > b.length) { | ||
| throw new RuntimeException("Output mismatch on line :" + max | ||
| + ", a=" + a[max] | ||
| + ", b=<none>"); | ||
|
|
||
| } | ||
| if (a.length < b.length) { | ||
| throw new RuntimeException("Output mismatch on line :" + max | ||
| + ", a=<none>" | ||
| + ", b=" + b[max]); | ||
| } |
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.
Should these checks be done before the "for" loop at line 756? Otherwise, could one of the array be indexed out-out-bound?
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.
Thanks for finding the bug. I have fixed it in version 2e6af77. I also tested locally with this code:
String[] a = {"1", "2"}, b = {"1"};
TestCommon.linesMustMatch(a, b);
which correctly produces this error:
java.lang.RuntimeException: Output mismatch on line 1: a=2, b=<none>
cl4es
left a comment
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 patch ensures that the methods in the LF holder classes at least contain the set of methods as generated by jlink at build, which seems to me to be reasonable to hold as an invariant to avoid surprises at runtime. (Does resolving a LF from a holder does trigger emitting a @lambda-form-invoker line when generating the classlist?)
|
@iklam 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 46 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. ➡️ To integrate this PR with the above commit message to the |
calvinccheung
left a comment
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.
Updates look good. Thanks.
The jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java Lines 122 to 131 in 5699041
This is the same place where GenerateLinkOptData.gmk gathers information for generating the Holder classes for the JDK's module image. |
…not be affected by -Xlog options
calvinccheung
left a comment
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.
Test changes look good.
|
Thanks to @calvinccheung and @cl4es for the review. |
|
Going to push as commit 90fb9a0.
Your commit was automatically rebased without conflicts. |
The
@lambda-form-invokerlines in the default classlist ($JAVA_HOME/lib/classlist) control what lambda-form invoker methods are added to these classes that are generated during a CDS dump (see here):java.lang.invoke.Invokers$Holderjava.lang.invoke.DirectMethodHandle$Holderjava.lang.invoke.DelegatingMethodHandle$Holderjava.lang.invoke.LambdaForm$HolderThe list of these invoker methods is generated as part of the JDK build process. They are used for invoking MethodHandles of commonly-used types, so that we can avoid generating custom LambdaForm classes.
When a CDS archive is created with a non-default classlist, (e.g.,
-XX:SharedClassListFile=foo.classlist), such a classlist may not contain all the@lambda-form-invokerlines as in the default classlist. As a result, at runtime, more custom LambdaForm classes may be generated than necessary.The solution is to always load the
@lambda-form-invokerlines from the default classlist, to make sure the CDS image has all the commonly-used invoker methods.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10639/head:pull/10639$ git checkout pull/10639Update a local copy of the PR:
$ git checkout pull/10639$ git pull https://git.openjdk.org/jdk pull/10639/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10639View PR using the GUI difftool:
$ git pr show -t 10639Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10639.diff