Community
Participate
Working Groups
Build ID: M20080221-1800 Steps To Reproduce: 1. Create an enum 2. Try to initialize static field inside enum constructor 3.As per jdk 1.6 specification it should fail but eclipse 3.3.2 didn't complain anything but javac compiler failed to compile when I try to compile in windows command line More information: public enum TestEnum { RED, GREEN, BLUE; static int test = 0; TestEnum() { TestEnum.test=10; } } Current behavior in Eclipse 3.3.2 - No error Correct behavior TestEnum.java:8: illegal reference to static field from initializer TestEnum.test=10;
Jdk : jdk1.6.0_05 Eclipse : eclipse 3.3.2
Reproduced with HEAD. This used to be compiled fine with JDK1.5.0, but it now fails with JDK6.
Added EnumTest#test153-161. Support was incorrectly only considering implict static field accesses (see bug 101713). It should reject any such reference to an enum static field member.
Created attachment 98656 [details] Proposed patch
Javac 5 does not detect non implicit references either; but this feels a bug as per JLS (i.e. will make the fix for all compliance levels).
Released for 3.4RC1 Fixed
+1 for 3.4RC1
Verified for3.4RC1 using I20080510-2000
*** Bug 242885 has been marked as a duplicate of this bug. ***