-
Bug
-
Resolution: Unresolved
-
P4
-
7
-
Fix Understood
-
x86
-
linux
Run:
---%<---
public class CaS_CCE {
public static void main(String[] x) {
try {
Object o = "";
Integer i = (Integer) o;
} catch (ClassCastException e) {
System.out.println(e.getMessage());
}
try {
Object o = "";
Integer i = Integer.class.cast(o);
} catch (ClassCastException e) {
System.out.println(e.getMessage());
}
try {
Class<?> c = String.class;
Class<? extends Integer> i = c.asSubclass(Integer.class);
} catch (ClassCastException e) {
System.out.println(e.getMessage());
}
}
}
---%<---
I get:
---%<---
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b04)
Java HotSpot(TM) Client VM (build 1.7.0-ea-b04, mixed mode, sharing)
java.lang.String cannot be cast to java.lang.Integer
Cannot cast java.lang.String to java.lang.Integer
class java.lang.String
---%<---
That last message is not too helpful. #6456938 fixed the second one.
---%<---
public class CaS_CCE {
public static void main(String[] x) {
try {
Object o = "";
Integer i = (Integer) o;
} catch (ClassCastException e) {
System.out.println(e.getMessage());
}
try {
Object o = "";
Integer i = Integer.class.cast(o);
} catch (ClassCastException e) {
System.out.println(e.getMessage());
}
try {
Class<?> c = String.class;
Class<? extends Integer> i = c.asSubclass(Integer.class);
} catch (ClassCastException e) {
System.out.println(e.getMessage());
}
}
}
---%<---
I get:
---%<---
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b04)
Java HotSpot(TM) Client VM (build 1.7.0-ea-b04, mixed mode, sharing)
java.lang.String cannot be cast to java.lang.Integer
Cannot cast java.lang.String to java.lang.Integer
class java.lang.String
---%<---
That last message is not too helpful. #6456938 fixed the second one.
- relates to
-
JDK-6456938 (reflect) Class.cast(Object) throws CCE without detail message
- Closed