-
Bug
-
Resolution: Fixed
-
P3
-
7
-
b18
-
generic
-
generic
-
Not verified
Experience has shown that refactoring complex exception detail message
constructions to a separate method tends to improve performance
with JDK's runtime compilers.
--- /u/martin/ws/dolphin/src/share/classes/java/lang/Class.java 2007-06-28 14:57:58.260063000 -0700
+++ /u/martin/ws/checked/src/share/classes/java/lang/Class.java 2007-07-26 16:55:10.570075000 -0700
@@ -3005,11 +3005,14 @@
*/
public T cast(Object obj) {
if (obj != null && !isInstance(obj))
- throw new ClassCastException("Cannot cast " + obj.getClass().getName()
- + " to " + getName());
+ throw new ClassCastException(cannotCastMsg(obj));
return (T) obj;
}
+ private String cannotCastMsg(Object obj) {
+ return "Cannot cast " + obj.getClass().getName() + " to " + getName();
+ }
+
/**
* Casts this {@code Class} object to represent a subclass of the class
* represented by the specified class object. Checks that that the cast
constructions to a separate method tends to improve performance
with JDK's runtime compilers.
--- /u/martin/ws/dolphin/src/share/classes/java/lang/Class.java 2007-06-28 14:57:58.260063000 -0700
+++ /u/martin/ws/checked/src/share/classes/java/lang/Class.java 2007-07-26 16:55:10.570075000 -0700
@@ -3005,11 +3005,14 @@
*/
public T cast(Object obj) {
if (obj != null && !isInstance(obj))
- throw new ClassCastException("Cannot cast " + obj.getClass().getName()
- + " to " + getName());
+ throw new ClassCastException(cannotCastMsg(obj));
return (T) obj;
}
+ private String cannotCastMsg(Object obj) {
+ return "Cannot cast " + obj.getClass().getName() + " to " + getName();
+ }
+
/**
* Casts this {@code Class} object to represent a subclass of the class
* represented by the specified class object. Checks that that the cast
- relates to
-
JDK-6456938 (reflect) Class.cast(Object) throws CCE without detail message
-
- Closed
-
-
JDK-6587525 ClassCastException needs "origin" and "target" attributes
-
- Closed
-