Community
Participate
Working Groups
The following code produces invalid bytecode: <snip> public class EnumBug { interface Interface { public int value(); } public enum TheEnum implements Interface { ; TheEnum(int value) { this.value = value; } public int value() { return value; } private int value; } public static void main(String[] args) { TheEnum x = null; } } </snip> Error when executing: java.lang.ClassFormatError: Illegal class modifiers in class EnumBug: 0x4419 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) Exception in thread "main" --- The same code compiles / executes fine with the Sun JDK compiler.
I'll investigate.
We are wrong to set the abstract bit when the enum type has no enum constant. This bit should be set only when some enum constants don't define the interface method.
Created attachment 49656 [details] Proposed fix
Released for 3.3M2. Fixed and released in HEAD. Added regression test in org.eclipse.jdt.core.tests.compiler.regression.EnumTest#test137
Verified for 3.3 M2 using build I20060918-0010.