Bug 266466

Summary: [1.5][compiler] Wrong Error "Cannot reference a field before it is definied" in enums since 3.4.2
Product: [Eclipse Project] JDT Reporter: max schroeder <schroeder>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann
Version: 3.4.2   
Target Milestone: 3.5 M6   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description max schroeder CLA 2009-02-27 06:13:12 EST
Since the latest update I got a compiler error whereas I didn't get one in 3.4.1
Eclipse complains about the usage of an static field declared in an enum in the constructor of an enum instance. look at the following code:

public class Demo
{	
	public static class CLAZZ
	{
		public static CLAZZ demo = new CLAZZ(CLAZZ.test);
		
		public CLAZZ(String string)
		{
			myString = string;
		}
		
		public static String test = "test";
		
		final String myString;
	}
	
	public static enum ENUM
	{
		
		TEST1(ENUM.test);
		
		private ENUM(String string)
		{
			myString = string;
		}
		
		public static String test = "test";
		
		final String myString;
	}
	
}

The CLAZZ doesn't show the error, where the ENUM tells me about the error on the declaration of the sole instance. My javac dosen't bother about this class and so should the eclipse compiler...
Comment 1 Olivier Thomann CLA 2009-02-27 08:30:25 EST

*** This bug has been marked as a duplicate of bug 263877 ***
Comment 2 Frederic Fusier CLA 2009-03-10 15:03:42 EDT
Verified for 3.5M6 using I20090310-0100.