Name: clC74495 Date: 05/31/98
===================================================================
Carlos.Lucasius@Canada (May 31, 1998):
This RFE was initially reported for JDK1.1.6, but it also
applies to JDK1.2beta4.
Report follows:
Consider in java.text.NumberFormat.java the following
method definition:
public final StringBuffer format(Object number,
StringBuffer toAppendTo,
FieldPosition pos)
{
if (number instanceof Double || number instanceof Float) {
return format(((Number)number).doubleValue(), toAppendTo, pos);
}
else if (number instanceof Number) {
return format(((Number)number).longValue(), toAppendTo, pos);
}
else {
throw new IllegalArgumentException("Cannot format given Object as a Number");
}
}
It takes in an Object as input, but within the code you are
checking to see if the object is at least an instance of Number.
This being the case, why don't you take a Number as input
rather than an Object. This would make better compile time
checking, and less internal work (quicker!)
(Review ID: 29410)
======================================================================
- relates to
-
JDK-4271940 Compiler doesn't catch static type error: usage unlike method signature
-
- Closed
-