Community
Participate
Working Groups
Compiling the following enum using Eclipse 3.3 M6: public enum TestEnum { C { @Override public boolean test() { return true; } }; static { for (int i = 0; i < 1; i++) { } } public boolean test() { return false; } } Produces the following static initializer with an incorrect stackmap: static {}; Code: Stack=6, Locals=1, Args_size=0 0: new #12; //class TestEnum$1 3: dup 4: ldc #14; //String C 6: iconst_0 7: invokespecial #15; //Method TestEnum$1."<init>":(Ljava/lang/String;I)V 10: putstatic #19; //Field C:LTestEnum; 13: iconst_1 14: anewarray #1; //class TestEnum 17: dup 18: iconst_0 19: getstatic #19; //Field C:LTestEnum; 22: aastore 23: putstatic #21; //Field ENUM$VALUES:[LTestEnum; 26: iconst_0 27: istore_0 28: goto 34 31: iinc 0, 1 34: iload_0 35: iconst_1 36: if_icmplt 31 39: return LineNumberTable: line 3: 0 line 6: 26 line 2: 39 LocalVariableTable: Start Length Slot Name Signature 28 11 0 i I StackMapTable: number_of_entries = 2 frame_type = 255 /* full_frame */ offset_delta = 31 locals = [ int ] stack = [ uninitialized 0, uninitialized 0 ] frame_type = 255 /* full_frame */ offset_delta = 2 locals = [ int ] stack = [ uninitialized 0, uninitialized 0 ] This stackmap fails to verify: bin> java -XX:-FailOverToOldVerifier -classpath . TestEnum Exception in thread "main" java.lang.VerifyError: Inconsistent stackmap frames at branch target 34 in method TestEnum.<clinit>()V at offset 28 If the overridden method "test" is removed from "C", then the problem disappears.
Thanks for the report. Reproduced. Fix under testing.
Released for 3.3M7. Added regression tests org.eclipse.jdt.core.tests.compiler.regression.StackMapAttributeTest.test033() org.eclipse.jdt.core.tests.compiler.regression.StackMapAttributeTest.test034()
Verified for 3.3 M7 using build I20070427-0010