Bug 108905 - [1.5][compiler] Compiler accepts invalid enum initializers
Summary: [1.5][compiler] Compiler accepts invalid enum initializers
Status: RESOLVED DUPLICATE of bug 101713
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-07 03:22 EDT by Erling Ellingsen CLA
Modified: 2005-09-07 09:41 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erling Ellingsen CLA 2005-09-07 03:22:34 EDT
From the java language spec section 8.9:

It is a compile-time error to reference a static field of an enum type that is not [final] from constructors 
[...].

The following compiles with the eclipse compiler, but not with javac:

public enum Static {
	A(1),B(3);	
	static int used = 0;
	final int pos;
	Static(int j) {
		pos = used += j;
	}	
}
Comment 1 Philipe Mulet CLA 2005-09-07 09:41:47 EDT

*** This bug has been marked as a duplicate of 101713 ***