FULL PRODUCT VERSION :
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
javac 1.8.0_121
ADDITIONAL OS VERSION INFORMATION :
OSX 10.12.4 (16E195)
16.5.0 Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
See code snippet below.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the provided code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Graceful exit.
ACTUAL -
Compiles fine, but fails runtime, see error messages below.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
slask/Outer$Producer.lambda$new$0(Lslask/Outer;)Ljava/lang/Object; @5: getfield
Reason:
Type 'slask/Outer' (current frame, stack[2]) is not assignable to 'slask/Outer$Producer'
Current Frame:
bci: @5
flags: { }
locals: { 'slask/Outer' }
stack: { uninitialized 0, uninitialized 0, 'slask/Outer' }
Bytecode:
0x0000000: bb00 0559 2ab4 0003 b700 06b0
at slask.Outer.main(Outer.java:9)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package slask;
import java.util.function.Supplier;
public class Outer
{
public static void main(String[] args)
{
new Outer().new Producer();
}
class Inner { }
class Producer {
Producer() {
this(Inner::new); // Should work but fails runtime
//this(() -> new Inner()); // Also fails
//this(() -> Outer.this.new Inner()); // Workaround that works
}
Producer(Supplier<Object> supplier) { }
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
See commented out line with workaround comment in source code.
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
javac 1.8.0_121
ADDITIONAL OS VERSION INFORMATION :
OSX 10.12.4 (16E195)
16.5.0 Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
See code snippet below.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the provided code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Graceful exit.
ACTUAL -
Compiles fine, but fails runtime, see error messages below.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
slask/Outer$Producer.lambda$new$0(Lslask/Outer;)Ljava/lang/Object; @5: getfield
Reason:
Type 'slask/Outer' (current frame, stack[2]) is not assignable to 'slask/Outer$Producer'
Current Frame:
bci: @5
flags: { }
locals: { 'slask/Outer' }
stack: { uninitialized 0, uninitialized 0, 'slask/Outer' }
Bytecode:
0x0000000: bb00 0559 2ab4 0003 b700 06b0
at slask.Outer.main(Outer.java:9)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package slask;
import java.util.function.Supplier;
public class Outer
{
public static void main(String[] args)
{
new Outer().new Producer();
}
class Inner { }
class Producer {
Producer() {
this(Inner::new); // Should work but fails runtime
//this(() -> new Inner()); // Also fails
//this(() -> Outer.this.new Inner()); // Workaround that works
}
Producer(Supplier<Object> supplier) { }
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
See commented out line with workaround comment in source code.
- duplicates
-
JDK-8182401 Verification error for enclosing instance capture inside super constructor invocation
-
- Resolved
-