Bug 93789 - [1.5][compiler] Compiler incorrectly allows static declarations in enum constants.
Summary: [1.5][compiler] Compiler incorrectly allows static declarations in enum const...
Status: CLOSED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.1 RC2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-05 10:56 EDT by David Gates CLA
Modified: 2005-06-10 10:20 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 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