-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
b20
The @lambda-form-invoker lines 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 [1]:
java.lang.invoke.Invokers$Holder
java.lang.invoke.DirectMethodHandle$Holder
java.lang.invoke.DelegatingMethodHandle$Holder
java.lang.invoke.LambdaForm$Holder
The list of these invoker methods is generated as part of the JDK build process [2]. 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-invoker lines 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-invoker lines from the default classlist, to make sure the CDS image has all the commonly-used invoker methods.
[1] https://github.com/iklam/jdk/blob/5aa997b001367141a6a2d2e69649d41b46199ab4/src/hotspot/share/cds/lambdaFormInvokers.cpp#L230
[2] https://github.com/iklam/jdk/blob/1996f649a3a30b7ac4b547a762417f807f5fa414/make/GenerateLinkOptData.gmk#L64
java.lang.invoke.Invokers$Holder
java.lang.invoke.DirectMethodHandle$Holder
java.lang.invoke.DelegatingMethodHandle$Holder
java.lang.invoke.LambdaForm$Holder
The list of these invoker methods is generated as part of the JDK build process [2]. 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-invoker lines 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-invoker lines from the default classlist, to make sure the CDS image has all the commonly-used invoker methods.
[1] https://github.com/iklam/jdk/blob/5aa997b001367141a6a2d2e69649d41b46199ab4/src/hotspot/share/cds/lambdaFormInvokers.cpp#L230
[2] https://github.com/iklam/jdk/blob/1996f649a3a30b7ac4b547a762417f807f5fa414/make/GenerateLinkOptData.gmk#L64