Community
Participate
Working Groups
The attaced java file will compile when using javac with the following JDK: java version "1.5.0_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode) Eclipse gives the following compilation error: Cannot refer to enum field State.INITIAL within an initializer I have seen bugs similar to the topic (such as #101713) however the notes claim that bug was fixed in a September release of 3.1.1 This problem appears in the most recent 3.1.1 release and 3.1.2 release making me believe it is different.
Created attachment 45479 [details] Sample enum that should compile
javac 6.0b88 agrees with us: X.java:5: illegal reference to static field from initializer System.out.printf("After the %s constructor\n",INITIAL); ^ 1 error but javac 1.5.0_07 compiles it fine. Looks like a bug has been fixed. If you qualify the access, then it compiles fine with both Eclipse and javac 6.0b88. public enum State { INITIAL , OPENED { { System.out.printf("After the %s constructor\n",State.INITIAL); } } } Closing as dup of bug 101713. *** This bug has been marked as a duplicate of 101713 ***
Added regression test org.eclipse.jdt.core.tests.compiler.regression.EnumTest.test134