Bug 108905

Summary: [1.5][compiler] Compiler accepts invalid enum initializers
Product: [Eclipse Project] JDT Reporter: Erling Ellingsen <reg.ecbz>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: 3.1.1   
Hardware: All   
OS: All   
Whiteboard:

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 ***