Bug in switch around Enums?
Matthias Ernst
matthias at mernst.org
Sat Sep 29 03:15:21 PDT 2007
Ted,
according to the JLS it's not a bug.
Switch labels can either be constant expressions or enum identifiers:
http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.11
SwitchLabel:
case ConstantExpression :
case EnumConstantName :
default :
and constant expression is only defined for primitives and String:
http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.28
So (STAGGER) is neither a constant expression nor an enum constant name.
Feel free to call me type 1
(http://diveintomark.org/archives/2004/08/16/specs) :-)
Matthias
More information about the compiler-dev
mailing list