JDK-8247666 : Support Lambda proxy classes in static CDS archive
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-06-16
  • Updated: 2020-10-28
  • Resolved: 2020-10-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 16
16 b21Fixed
Related Reports
Relates :  
Description
This is the next step of JDK-8198698 - Support Lambda proxy classes in dynamic CDS archive.

Design -- when -XX:DumpLoadedClassList is enabled, print out the constant pool entries related to LambdaMetafactory that are resolved during application execution. This will appear in the classlist like this (exact format TBD)

    com/foo/HelloWorld indy_index: 4
    com/foo/HelloWorld indy_index: 6

During -Xshare:dump, when we see such "indy_index" entries in the classfile, we will resolve constant pool #4 and #6. In doing so, Lambda proxy classes will be generated for these two constant pool entries, and can be cached in a way that's similar to JDK-8198698.

Comments
Changeset: 74ac77e2 Author: Calvin Cheung <ccheung@openjdk.org> Date: 2020-10-19 18:27:50 +0000 URL: https://git.openjdk.java.net/jdk/commit/74ac77e2
19-10-2020

Classlist entry format for a lambda proxy class: @lambda-proxy <classname> <intf-method-name> <intf-method-sig> <bsm-arg0> <bsm-arg1a> <bsm-arg1b> <bsm-arg1c> <bsm-arg1d> <bsm-arg2> It is a symbolic representation of a invoke dynamic constant pool entry. public class LambHello { public static void main(String[] args) { doit(() -> { System.out.println("Hello from Lambda"); }); } static void doit(Runnable t) { t.run(); } } An invoke dynamic constant pool of the above program is: - 7 : InvokeDynamic : bootstrap_method_index=43 name_and_type_index=8 arguments={50, 51, 50} Other constant pool entries related to the above are: - 8 : NameAndType : name_index=9 signature_index=10 - 9 : Utf8 : 'run' - 10 : Utf8 : '()Ljava/lang/Runnable;' - 50 : MethodType : signature_index=6 - 51 : MethodHandle : ref_kind=6 ref_index=52 - 52 : Method : klass_index=12 name_and_type_index=53 - 53 : NameAndType : name_index=39 signature_index=6 - 6 : Utf8 : '()V' - 12 : Class : 'LambHello' {0x0000000800c10040} - 39 : Utf8 : 'lambda$main$0' The info included in the classlist are: <classname> = LambHello <intf-method-name> = run <intf-method-sig> = ()Ljava/lang/Runnable; <bsm-arg0> = ()V <bsm-arg1a> = REF_invokeStatic <bsm-arg1b> = LambHello <bsm-arg1c> = lambda$main$0 <bsm-arg1d> = ()V <bsm-arg2> = ()V A classlist entry for the above lambda proxy class is: @lambda-proxy LambHello run ()Ljava/lang/Runnable; ()V REF_invokeStatic LambHello lambda$main$0 ()V ()V
19-10-2020

I have a very old prototype for Lambda proxy support in static CDS archive: http://cr.openjdk.java.net/~iklam/design/misc/static-archive-lambda-2018/ Most of the code is irrelevant, but you can see how the "indy_index" is printed for -XX:DumpLoadedClassList in linkResolver.cpp, and processed by classListParser.cpp
16-06-2020