Community
Participate
Working Groups
The following test case fails when compiled in eclipse, but passes when compiled with the Sun JDK. Tested against integration build 3.1_I20050126-0800. ---- EnumTest.java ---- import junit.framework.TestCase; public class EnumTest extends TestCase { /* * MyEnum has a non-null, private constructor, and ITEM is an anonymous * subclass. These three factors together cause a VerifyError to be thrown. * Omit any one factor and the test passes. */ enum MyEnum { ITEM (0) {}; // curly braces make ITEM an anonymous subclass private MyEnum(int i) {} } public void testMyEnum() { try { MyEnum.values(); } catch (VerifyError ve) { fail(); } } /* * MyEnumNoAnonymousSubclass has a non-null, private constructor. No * VerifyError occurs. */ enum MyEnumNoAnonymousSubclass { ITEM (0); private MyEnumNoAnonymousSubclass(int i) {} } public void testMyEnumNoAnonymousSubclass() { try { MyEnumNoAnonymousSubclass.values(); } catch (VerifyError ve) { fail(); } } /* * MyEnumNonPrivateConstructor has a non-null constructor, and ITEM is an * anonymous subclass. No VerifyError occurs. */ enum MyEnumNonPrivateConstructor { ITEM (0) {}; MyEnumNonPrivateConstructor(int i) {} } public void testMyEnumNonPrivateConstructor() { try { MyEnumNonPrivateConstructor.values(); } catch (VerifyError ve) { fail(); } } /* * MyEnumNullConstructor has a private constructor, and ITEM is an anonymous * subclass. No VerifyError occurs. */ enum MyEnumNullConstructor { ITEM () {}; private MyEnumNullConstructor() {} } public void testMyEnumNullConstructor() { try { MyEnumNullConstructor.values(); } catch (VerifyError ve) { fail(); } } }
I will investigate.
Reproduced. Exception in thread "main" java.lang.VerifyError: (class: X, method: <init> signature: (Ljava/lang/String;IILX;)V) Register 1 contains wrong type Test case is: enum X { ITEM (0) {}; // curly braces make ITEM an anonymous subclass private X(int i) {} public static void main(String[] args) { for (X x : values()) { System.out.println(x); } } } The line: 3 iload_1 is boggus. It should be: 3 iload_3 // Method descriptor #73 (Ljava/lang/String;IILX;)V // Stack: 4, Locals: 5 synthetic X(String arg, int arg, int arg, X arg); 0 aload_0 [local_0] 1 aload_1 [local_1] 2 iload_2 [local_2] 3 iload_1 [local_1] 4 invokespecial X.<init>(Ljava/lang/String;II)V [74] 7 return Line numbers: [pc: 0, line: 4]
Created attachment 17526 [details] Apply on CodeStream
Patch looks good. I would write it though: if (declaringClass.erasure().id == T_JavaLangEnum || declaringClass.isEnum()) { this.aload_1(); // pass along name param as name arg this.iload_2(); // pass along ordinal param as ordinal arg resolvedPosition += 2; }
Fixed and released in HEAD. Regression test added in EnumTest.test066.
Verified in I20050215-2300