FULL PRODUCT VERSION :
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) Client VM (build 25.102-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
This appears to be quite similar toJDK-8129740 but does not involve lambdas.
The code compiles but produces VerifyError when runs. Possibly the compiler should not have allowed it at all, as the anonymous inner class is non-static code in the class being instantiated, and the supertype constructor has not been entered yet.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the supplied code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Probably a compiler error.
ACTUAL -
Successful compilation, but a runtime error.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
javacbug.<init>()V @18: invokespecial
Reason:
Type uninitializedThis (current frame, stack[3]) is not assignable to 'javacbug'
Current Frame:
bci: @18
flags: { flagThisUninit }
locals: { uninitializedThis }
stack: { uninitializedThis, uninitialized 1, uninitialized 1, uninitializedThis, 'Outer' }
Bytecode:
0x0000000: 2abb 0001 592a bb00 0259 b700 0359 b600
0x0000010: 0457 b700 05b7 0006 b1
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class Base {
Base(Object o) {}
}
class Outer {
class Inner {}
}
class javacbug extends Base {
javacbug() { super(new Outer().new Inner() {}); }
public static void main(String[] args) { new javacbug(); }
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Instantiate the Inner object somewhere else; either a static method, or after the supertype constructor has returned.
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) Client VM (build 25.102-b14, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
This appears to be quite similar to
The code compiles but produces VerifyError when runs. Possibly the compiler should not have allowed it at all, as the anonymous inner class is non-static code in the class being instantiated, and the supertype constructor has not been entered yet.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the supplied code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Probably a compiler error.
ACTUAL -
Successful compilation, but a runtime error.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
javacbug.<init>()V @18: invokespecial
Reason:
Type uninitializedThis (current frame, stack[3]) is not assignable to 'javacbug'
Current Frame:
bci: @18
flags: { flagThisUninit }
locals: { uninitializedThis }
stack: { uninitializedThis, uninitialized 1, uninitialized 1, uninitializedThis, 'Outer' }
Bytecode:
0x0000000: 2abb 0001 592a bb00 0259 b700 0359 b600
0x0000010: 0457 b700 05b7 0006 b1
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
class Base {
Base(Object o) {}
}
class Outer {
class Inner {}
}
class javacbug extends Base {
javacbug() { super(new Outer().new Inner() {}); }
public static void main(String[] args) { new javacbug(); }
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Instantiate the Inner object somewhere else; either a static method, or after the supertype constructor has returned.