Community
Participate
Working Groups
3.2M4 It seems to be disallowed to create explicit, named subclasses of Enum. But anonymous subclasses are not disallowed. Not sure if this is a bug in the compiler or hole in the spec or just a bizzare feature of the language. //no error here Enum e= new Enum("foo", 2){ public int compareTo(Object o) { return 0; } } class B extends Enum{ } //error here
The first case that doesn't fail to compile reports: Exception in thread "main" java.lang.VerifyError: (class: X$1, method: <init> signature: (Ljava/lang/String;I)V) Expecting to find unitialized object on stack at X.main(X.java:7) at runtime.
Created attachment 40608 [details] Proposed fix
Created attachment 40609 [details] Regression test
Fix looks good. +1 for 3.2RC4 Darin/Dani: pls cast your vote. Fix is trivial (exact same check we perform when connecting superclasses, but anonymous use a different codepath which didn't check).
Dani - pls vote
Looked at the patch - approving for 3.2 RC4.
+1
Fixed and released in HEAD. Regression test added in org.eclipse.jdt.core.tests.compiler.regression.EnumTest.test128
Verified with I20060511-2000 for 3.2RC4