FULL PRODUCT VERSION : java version "1.7.0_71" Java(TM) SE Runtime Environment (build 1.7.0_71-b14) Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode) ADDITIONAL OS VERSION INFORMATION : Linux steve-virtual-machine 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux ( EXTRA RELEVANT SYSTEM CONFIGURATION : It is believed this issue is machine/hardware independent. A DESCRIPTION OF THE PROBLEM : When the program below is compiled, a class file is produced. However, when this class is loaded (by running the main inside it for example), it produces a verifier error. This fails for Java7 and Java8, although not Java6. BTW, I do not know if this is a compiler bug, or a verifier bug. It should be noted that the example below is a refinement of the result of some automatic code generation. As such, it is merely an example of a non-working method. The 'real world' effect of this is hat the code generation for some input is correct java syntax in that it goes through the compiler, but it does not execute at all. REGRESSION. Last worked in version 6u45 STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Compile the example code, and try to execute it. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - $ javac VerifyBug.java $ java VerifyBug ACTUAL - $ javac VerifyBug.java $ java VerifyBug Exception in thread "main" java.lang.VerifyError: Inconsistent stackmap frames at branch target 84 Exception Details: Location: VerifyBug.problematicMethod(I)V @84: goto Reason: Type top (current frame, locals[4]) is not assignable to long (stack map, locals[4]) Current Frame: bci: @51 flags: { } locals: { 'VerifyBug', integer } stack: { integer } Stackmap Frame: bci: @84 flags: { } locals: { 'VerifyBug', integer, top, top, long, long_2nd } stack: { } Bytecode: 0000000: 1bab 0000 0000 0028 0000 0002 0000 0002 0000010: 0000 001e 0000 0003 0000 001b a700 0007 0000020: 3604 1b10 109f 0007 b1a7 0000 1b10 079f 0000030: 0028 1bab 0000 0024 0000 0002 0000 0001 0000040: 0000 0019 0000 0002 0000 0021 1400 0237 0000050: 04a7 0006 a700 03b1 Stackmap Table: same_frame(@28) same_frame(@31) same_frame(@41) same_frame(@44) same_frame(@76) append_frame(@84,Top,Top,Long) chop_frame(@87,3) at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2615) at java.lang.Class.getMethod0(Class.java:2856) at java.lang.Class.getMethod(Class.java:1668) at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- public class VerifyBug { public static void main(String[] args) { } private void problematicMethod(int p) { switch (p) { case 3: long n; while (true) { if (false) { break; } } break; case 2: loop: while (true) { while (true) { int i = 4; if (p != 16) { return; } break loop; } } break; default: while (true) { if (false) { break; } } break; } long b; if (p != 7) { switch (p) { case 1: long a = 17; break; case 2: break; default: break; } } } } ---------- END SOURCE ----------
|