FULL PRODUCT VERSION :
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux Balakin-LP 4.4.0-96-generic #119-Ubuntu SMP Tue Sep 12 14:59:54 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Compiling a lambda expression in a super-constructor call within an inner class results a non-valid byte code
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile javac Outer.java
2. Run java Outer
ACTUAL -
Exception
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
Outer$Inner.lambda$new$0(LOuter;Ljava/lang/Object;)LOuter$Inner; @5: getfield
Reason:
Type 'Outer' (current frame, stack[2]) is not assignable to 'Outer$Inner'
Current Frame:
bci: @5
flags: { }
locals: { 'Outer', 'java/lang/Object' }
stack: { uninitialized 0, uninitialized 0, 'Outer' }
Bytecode:
0x0000000: bb00 0459 2ab4 0001 2bb7 0005 b0
at Outer.main(Outer.java:17)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.function.Function;
class Outer {
static class Super {
Super(Function<Object, Inner> creator) {}
}
class Inner extends Super {
Inner(Object something) {
super(Inner::new); // java.lang.VerifyError: Bad type on operand stack
// super(smt -> Outer.this.new Inner(smt)); // Workaround
}
}
public static void main(String[] args) {
new Outer().new Inner(42);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Instead of
super(Inner::new); // java.lang.VerifyError: Bad type on operand stack
Use
super(smt -> Outer.this.new Inner(smt)); // Workaround
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux Balakin-LP 4.4.0-96-generic #119-Ubuntu SMP Tue Sep 12 14:59:54 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Compiling a lambda expression in a super-constructor call within an inner class results a non-valid byte code
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile javac Outer.java
2. Run java Outer
ACTUAL -
Exception
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
Outer$Inner.lambda$new$0(LOuter;Ljava/lang/Object;)LOuter$Inner; @5: getfield
Reason:
Type 'Outer' (current frame, stack[2]) is not assignable to 'Outer$Inner'
Current Frame:
bci: @5
flags: { }
locals: { 'Outer', 'java/lang/Object' }
stack: { uninitialized 0, uninitialized 0, 'Outer' }
Bytecode:
0x0000000: bb00 0459 2ab4 0001 2bb7 0005 b0
at Outer.main(Outer.java:17)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.function.Function;
class Outer {
static class Super {
Super(Function<Object, Inner> creator) {}
}
class Inner extends Super {
Inner(Object something) {
super(Inner::new); // java.lang.VerifyError: Bad type on operand stack
// super(smt -> Outer.this.new Inner(smt)); // Workaround
}
}
public static void main(String[] args) {
new Outer().new Inner(42);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Instead of
super(Inner::new); // java.lang.VerifyError: Bad type on operand stack
Use
super(smt -> Outer.this.new Inner(smt)); // Workaround
- duplicates
-
JDK-8182401 Verification error for enclosing instance capture inside super constructor invocation
-
- Resolved
-