Bug 26652 - Encountered "case statement must be constant" error
Summary: Encountered "case statement must be constant" error
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.1 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-19 06:27 EST by Missing name CLA
Modified: 2002-11-21 05:35 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Missing name CLA 2002-11-19 06:27:07 EST
When migrating the java file which includes the case statement, created by 
VAJ4.0, I encountered an error "case statement must be constant".
The test program is a real customer's data, so I cannot attach it in bugzilla.
Please contact me off-line and I will send it.
Comment 1 Sonia Dimitrov CLA 2002-11-19 09:23:22 EST
Moving to JDT Core.
Comment 2 Philipe Mulet CLA 2002-11-20 09:31:02 EST
We did fix a couple cases where our compiler was too permissive. 

In particular, expressions denoting constants through a non-static references 
were incorrectly allowed. 

e.g.

public class X {
	public final static int CST = 1;
	public static void main(String[] arguments) {
		X x = new X();
		switch (1) {
			case x.CST : 
				break;
		}
	}
}

"case x.CST" should be replaced with "case X.CST" or simply "case CST" where it 
applies.

Ok to close? Or is your scenario different from this one ?
Comment 3 Philipe Mulet CLA 2002-11-21 05:35:33 EST
Closing, please reopen if you have a test case which we reject incorrectly.