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

Verifier error for lambda declared in early construction context

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 24
    • None
    • tools
    • b03
    • generic
    • generic

    Description

      The following class throws a verifier error when compiled in JDK 24:

      $ cat LambdaOuterCapture.java
      public class LambdaOuterCapture {

          public class Inner {

              public Inner() {
                  Runnable r = () -> System.out.println(LambdaOuterCapture.this);
                  this(r);
              }

              public Inner(Runnable r) {
              }
          }

          public static void main(String[] args) {
              new LambdaOuterCapture().new Inner();
          }
      }
      $ javac --enable-preview --release 24 LambdaOuterCapture.java
      $ java --enable-preview LambdaOuterCapture
      Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
      Exception Details:
        Location:
          LambdaOuterCapture$Inner.<init>(LLambdaOuterCapture;)V @1: invokedynamic
        Reason:
          Type uninitializedThis (current frame, stack[0]) is not assignable to 'LambdaOuterCapture$Inner'
        Current Frame:
          bci: @1
          flags: { flagThisUninit }
          locals: { uninitializedThis, 'LambdaOuterCapture' }
          stack: { uninitializedThis }
        Bytecode:
          0000000: 2aba 0001 0000 4d2a 2b2c b700 05b1

      at LambdaOuterCapture.main(LambdaOuterCapture.java:15)

      Attachments

        Issue Links

          Activity

            People

              acobbs Archie Cobbs
              acobbs Archie Cobbs
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: