Bug 97133

Summary: [1.5][compiler] Rephrase compiler error message for enum types in non-static contexts
Product: [Eclipse Project] JDT Reporter: Adam Vartanian <flooey>
Component: CoreAssignee: Maxime Daniel <maxime_daniel>
Status: RESOLVED INVALID QA Contact:
Severity: enhancement    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Adam Vartanian CLA 2005-05-28 21:34:35 EDT
The following code produces a compile-time error because enumerations are
implicitly static, and thus cannot appear inside a non-static member class
declaration:

public class TestClass {
	public class InnerClass {
		public enum InnerEnum { A, B, C }
	}
}

The error message given by the Eclipse compiler is:

The member type InnerEnum cannot be declared static; static types can only be
declared in static or top level types

This may cause confusion with normal Java programmers because, not having used
the static keyword, they may not realize that enumerations are static.  It also
implies that declaring InnerEnum as non-static would solve the problem (which is
impossible).  The javac compiler produces the following message, which I feel is
more friendly on both counts:

TestClass.java:20: enum declarations allowed only in static contexts
Comment 1 Philipe Mulet CLA 2005-05-29 15:17:36 EDT
Agreed.
Comment 2 Philipe Mulet CLA 2005-06-06 06:34:39 EDT
Actually, our error message reads already:
  The member enum InnerEnum must be defined inside a static member type

It clearly tells about enum type.