Community
Participate
Working Groups
Build ID: I20080617-2000 Steps To Reproduce: 1.Create a java project and set 'Installed JRE'jdk150_12 2.Create an enum class with a static field(See examples in More information) 3.Create a constructor and try to refer the static field, and a compiling error appears. 4.Detail error message: Cannot refer to the static enum field xxx with an initializer More information: /* The enum class can be successfully compiled by Eclipse 3.2, 3.3 and Javac(1.5) but fails compiling in Eclispe 3.4(Ganymede) */ package com.xxx.forms; import java.util.HashMap; import java.util.Map; /** * @author Raymondy * */ public enum FormId { T1P1("T1 P1"), T1P2("T1 P2"), T1P3("T1 P3"), T1P4("T1 P4"), UNKNOWN("Unknown"); private String name; private static Map<String, FormId> formIds = new HashMap<String, FormId>(); private FormId(String name) { this.name = name; FormId.formIds.put(name, this); } public String toString() { return name; } public static FormId getFormId(String formId) { return formIds.get(formId); } }
Closing as a dup of bug 228109. This code should not compile. This was a bug in the Eclipse compiler and javac 1.5 that has been fixed. *** This bug has been marked as a duplicate of bug 228109 ***
Verified for 3.5M2 using I20080914-2000 that the error is still correctly reported.