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

Verification error for enclosing instance capture inside super constructor invocation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 10
    • 8-pool, 9
    • tools
    • None
    • b36

    Description

      Tested with 9-ea+174 and 1.8.0_152-ea-b04. The same issue occurs with `super(f(s -> new A(s)));` instead of the constructor reference.

      ===
      import java.util.function.Function;

      class T {
        static Object f(Function<String, Object> f) { return null; }
        class S { S(Object s) {} }
        class A { A(String s) {} }
        class B extends S {
          B() {
            super(f(A::new));
          }
        }

        public static void main(String[] args) {
          new T().new B();
        }
      }
      ===

      $ javac T.java && java T
      Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
      Exception Details:
        Location:
          T$B.lambda$new$0(LT;Ljava/lang/String;)Ljava/lang/Object; @5: getfield
        Reason:
          Type 'T' (current frame, stack[2]) is not assignable to 'T$B'
        Current Frame:
          bci: @5
          flags: { }
          locals: { 'T', 'java/lang/String' }
          stack: { uninitialized 0, uninitialized 0, 'T' }
        Bytecode:
          0000000: bb00 0559 2ab4 0001 2bb7 0006 b0

      at T.main(T.java:14)

      Attachments

        Issue Links

          Activity

            People

              sadayapalam Srikanth Adayapalam (Inactive)
              cushon Liam Miller-Cushon
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: