Bug 93789

Summary: [1.5][compiler] Compiler incorrectly allows static declarations in enum constants.
Product: [Eclipse Project] JDT Reporter: David Gates <gatesda>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: CLOSED FIXED QA Contact:
Severity: minor    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description David Gates CLA 2005-05-05 10:56:55 EDT
Eclipse incorrectly compiles the following:
enum BugDemo {
	FOO() {
		static int bar;
	}
}

javac gives the error:
Foo.java:3: inner classes cannot have static declarations
                static int baz;
                           ^
1 error
Comment 1 Olivier Thomann CLA 2005-06-03 09:05:24 EDT
The problem comes from line 72 in
org.eclipse.jdt.internal.compiler.ast.FieldDeclaration.

We exclude wrongly enum from the check.
Comment 2 Philipe Mulet CLA 2005-06-06 06:12:16 EDT
Bug was found in 3.1M6
Comment 3 Philipe Mulet CLA 2005-06-06 06:28:39 EDT
Added EnumTest#test113.

Indeed, the #isClass() check can be removed, as subsequent #isStatic() check is
all we need here.

Fixed
Comment 4 Olivier Thomann CLA 2005-06-06 21:06:51 EDT
Verified in N20050606-0010 + JDT/Core HEAD
Comment 5 Jerome Lanneluc CLA 2005-06-10 10:20:48 EDT
Verified in I20050610-0010