Community
Participate
Working Groups
This problem occurs in Eclipse 3.1RC1. Compile the following enum using Eclipse 3.1RC1, and Enum1 has the accessFlags: 0x4021 Compile the enum using JDK 1.5 javac, and Enum1 has the accessFlags: 0x4031 The difference is the FINAL access flag. public enum Enum1 { ONE, TWO; public static void main(String[] args) throws Exception { System.out.println(Integer.toHexString(Enum1.class.getModifiers())); } }
I get 0x4001 using RC1 or any version of javac 1.5.
Created attachment 22842 [details] enum test case This is the test case that found the problem. The test passes on JDK when its been compiled with javac.
This is the javac I'm using: javac 1.5.0_03-ea java version "1.5.0_03-ea" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-ea-b04) Java HotSpot(TM) Client VM (build 1.5.0_03-ea-b04, mixed mode)
+1 for RC3 Dani - would you pls cast a vote on it ? Our compiler isn't producing valid files without it.
+1 for 3.1 RC3.
Indeed an enum type is implicitely final if none of its constants has a body. So the first example: public enum X { ONE, TWO } leads to a final bit set in the classfile. Whereas the classfile for public enum X { ONE() { public String toString() { return "1"; } }, TWO; } doesn't have the final bit set.
Created attachment 22923 [details] Fix the final bit issue.
Created attachment 22952 [details] This is the right patch
Created attachment 22953 [details] Patch for the test094
Created attachment 22954 [details] Simplified patch
Added EnumTest test114
Output is now: // Compiled from X.java (version 1.5 : 49.0, super bit) // Signature: Ljava/lang/Enum<LX;>; public final enum X extends java.lang.Enum { ... Verified using N20050616-0010 + JDT/Core HEAD