Community
Participate
Working Groups
Build ID: I20070625-1500 Steps To Reproduce: Write a simple switch statement with an invalid switch expression. e.g.: boolean t = true; switch(t) { case 1: System.out.println("1"); break; } The error message generated by the Eclipse compiler is: "Cannot switch on a value of type boolean. Only int values or enum constants are permitted" More information: In fact, this error message isn't entirely accurate. As per the JLS, there are more permitted values than just int and enum constants. Ref. JLS 14.11: "The type of the Expression must be char, byte, short, int, Character, Byte, Short, Integer, or an enum type (ยง8.9), or a compile-time error occurs." The second sentence of the error message should be updated to reflect the full range of allowed data types in a switch expression.
Note that wrapper types are only allowed in Java5... I'd vote for a less specific error message which would fit all scenarii. "Cannot switch on a value of type boolean. Only int convertible values or enum constants are permitted" Kent ? (if you agree pls perform the change in 3.4 stream, and update the tests if any)
Changed to "Cannot switch on a value of type boolean. Only convertible int values or enum constants are permitted" Fixed up SwitchTests.test010()
Verified for 3.4M2 using I20070917-0010