Community
Participate
Working Groups
hi, if you compile a switch statement on an enum type under javac, then it rejects code which compiles without error under the compiler built into eclipse. javac does not accept enumeration constants in parentheses. the compiler built into eclipse does. An example is enum Foo { A, B } Foo foo = 1==1 ? A : B; switch(foo) { case (A): System.out.println(" a "); break; case (B): System.out.println(" b "); break; } javac will complain about this, while the eclipse compiler won't. The Java Language Spec. appears to agree with javac from my understanding. http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.11
This is a known bug of javac. (A) is a constant expression and therefore should be accepted.
*** Bug 108701 has been marked as a duplicate of this bug. ***
*** This bug has been marked as a duplicate of 105592 ***
This is indeed invalid. See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6356542