Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8009649

Lambda back-end should generate invokespecial for method handles referring to private instance methods

    XMLWordPrintable

Details

    • b84
    • Verified

    Description

      Example 2

      Source:

      public class InstanceLambda {

        public void m() {
          Runnable r = ()->m();
        }

      }

      ---

      javap of javac output (Lambda b76):

      Classfile /Users/dan/Dev/misc/classes/InstanceLambda.class
      ...
        BootstrapMethods:
          0: #16 invokestatic java/lang/invoke/LambdaMetafactory.metaFactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
            Method arguments:
              #17 invokeinterface java/lang/Runnable.run:()V
              #18 invokevirtual InstanceLambda.lambda$0:()V [***** Note invocation mode: invokevirtual *****]
              #19 ()V
      {
      ...
        public void m();
          flags: ACC_PUBLIC
          Code:
            stack=1, locals=2, args_size=1
               0: aload_0
               1: invokedynamic #2, 0 // InvokeDynamic #0:lambda$:(LInstanceLambda;)Ljava/lang/Runnable;
               6: astore_1
               7: return
      ...

        private void lambda$0();
          flags: ACC_PRIVATE, ACC_SYNTHETIC [***** Note access: private *****]
          Code:
            stack=1, locals=1, args_size=1
               0: aload_0
               1: invokevirtual #3 // Method m:()V
               4: return
      ...
      }

      Attachments

        Activity

          People

            mcimadamore Maurizio Cimadamore
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: