RFR: 8295102: Always load @lambda-form-invoker lines from default classlist
Ioi Lam
iklam at openjdk.org
Tue Oct 11 06:15:44 UTC 2022
On Tue, 11 Oct 2022 03:23:01 GMT, David Holmes <dholmes at openjdk.org> wrote:
> 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 `@lambda-form-invoker` lines in the classlist is to add extra invoker methods into these holder classes (according to the app's profile) to avoid runtime generation of LambdaForm classes. Therefore, when dumping the archive, these 4 classes are regenerated and populated with methods specified by the `@lambda-form-invoker` lines.
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
- Excessive LambdaForm classes may be generated at runtime if the app executes code outside of its profile
- It will cause complication in future CDS optimizations (e.g., [JDK-8293336](https://bugs.openjdk.org/browse/JDK-8293336))
The default classlist (also generated by GenerateLinkOptData.gmk) contains the `@lambda-form-invoker` lines to regenerate the exact same set of methods as in the JDK's module image (this is checked by the new test case). By always loading these lines, we can guarantee that when a Holder class is stored in the CDS archive, it will not be missing any of the methods that are in the modules image.
-------------
PR: https://git.openjdk.org/jdk/pull/10639
More information about the hotspot-runtime-dev
mailing list