Bug 266500 - "Cannot Reference a field before it is defined" failure in enum type
Summary: "Cannot Reference a field before it is defined" failure in enum type
Status: VERIFIED DUPLICATE of bug 263877
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.2   Edit
Hardware: All Windows Vista
: P3 normal (vote)
Target Milestone: 3.5 M6   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-27 10:42 EST by Kay Huber CLA
Modified: 2009-03-10 15:03 EDT (History)
0 users

See Also:


Attachments
Test project with example enum (2.01 KB, application/octet-stream)
2009-02-27 10:45 EST, Kay Huber CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kay Huber CLA 2009-02-27 10:42:51 EST
After updating my eclipse this morning to 3.4.2 Build M20090211-1700 I suddenly had an eclipse compiler error on an enum type in our projects which was previously working just fine.

I created a test project to verify and can reproduce the problem (test project attached):

Create an enum type with the following content:

public enum FailingEnum {

	// Following line: having the dummyField declared here causes "Syntax errors on tokens, delete tokens" compilation failure in Eclipse 3.4.2 Build M20090211-1700
	// javac confirms with "<identifier> expected"
	// public final static int dummyField = 1;

	// Following line correctly causes "Cannot reference a field before it is defined" compilation failure in Eclipse 3.4.2 Build M20090211-1700
	// javac confirms with "illegal forward reference"
	// SimpleEnumElement1(dummyField),

	// Following line _incorrectly_ causes "Cannot reference a field before it is defined" compilation failure in Eclipse 3.4.2 Build M20090211-1700
	// javac 1.6.0_06 compiles this line without problems.
	SimpleEnumElement2(FailingEnum.dummyField);

	public final static int dummyField = 1;

	private FailingEnum(int dummy) {

	}
}

with javac (checked with 1.6.0_06) this class compiles like this just fine. 
Eclipse however complains on line 13 with "Cannot Reference a field before it is defined":

SimpleEnumElement2(FailingEnum.dummyField);
Comment 1 Kay Huber CLA 2009-02-27 10:45:12 EST
Created attachment 127008 [details]
Test project with example enum
Comment 2 Kent Johnson CLA 2009-02-27 11:17:24 EST

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