Relates :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : java version "1.6.0-beta2" Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta2-b73) Java HotSpot(TM) Client VM (build 1.6.0-beta2-b73, mixed mode, sharing) A DESCRIPTION OF THE PROBLEM : The JLS 3 only allow to swicth on char, byte, short, int, Character, Byte, Short, Integer, or an enum type (see section 14.11) and not on type assignable without canversion in char, byte, short, int, Character, Byte, Short, Integer, or an enum type. With variance wilcard introduced in JDK 1.5), you can now create subtype of final type but you can't switch on it, the code below don't compile according to the spec. List<? extends Integer> list=Arrays.asList(1,2); switch(list.get(0)) { case 1: case 2: } I think the spec could be changed to let this code compile. R����mi Forax REPRODUCIBILITY : This bug can be reproduced always. CUSTOMER SUBMITTED WORKAROUND : use a temporary variable : List<? extends Integer> list=Arrays.asList(1,2); int value=list.get(0); switch() { case 1: case 2: }
|