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)
===
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)
- duplicates
-
JDK-8178444 Using lambda in inner class constructor for creating peer inner class causes runtime "java.lang.VerifyError: Bad type on operand stack"
- Closed
-
JDK-8188852 Javac compiler produces illegal bytecode
- Closed
- relates to
-
JDK-8209407 VerifyError is thrown for inner class with lambda
- Closed