On Wed, 14 Oct 2020 16:24:47 GMT, Calvin Cheung <cche...@openjdk.org> wrote:
>>> `@lambda-proxy: LambHello run ()Ljava/lang/Runnable; ()V 6 LambHello >>> lambda$main$0 ()V ()V` >> >> Can you explain the format? > > `@lambda-proxy LambHello run ()Ljava/lang/Runnable; ()V REF_invokeStatic > LambHello lambda$main$0 ()V ()V` > means > `@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 class list 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 Since the class list file is not intended for users to edit/modify but rather a configuration file given when -Xshare:dump is used, the format of `@lambda-proxy` entry is internal implementation details and so it's fine. BTW: for the method handle reference kind, does the entry have the value (e.g. 6) or the name ("REF_invokeStatic")? I see both formats are described in your different replies. > @lambda-proxy: LambHello run ()Ljava/lang/Runnable; ()V 6 LambHello > lambda$main$0 ()V ()V or > @lambda-proxy LambHello run ()Ljava/lang/Runnable; ()V REF_invokeStatic > LambHello lambda$main$0 ()V ()V ------------- PR: https://git.openjdk.java.net/jdk/pull/364