Bug 97133 - [1.5][compiler] Rephrase compiler error message for enum types in non-static contexts
Summary: [1.5][compiler] Rephrase compiler error message for enum types in non-static ...
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.1 RC2   Edit
Assignee: Maxime Daniel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-28 21:34 EDT by Adam Vartanian CLA
Modified: 2005-06-06 06:34 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 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.