The specification for the methods {Float, Double}.valueOf (which convert strings into floating-point values) states "Leading and trailing whitespace characters in s are ignored." However, what characters are considered whitespace is not defined. The methods indirectly calls trim on the string. The trim method discards ASCII control characters but not the many other characters considered whitespace in unicode or Java. So the current implementation both accepts strings that should not be accepted (those with control characters) and rejects strings that should be accepted (those with non-ASCII whitespace).
This should be fixed.
This should be fixed.
- relates to
-
JDK-4487183 RFE: Want primitive wrapper classes to be able to test for NumberFormatException
-
- Closed
-
-
JDK-4707389 {Float, Double}.valueOf erroneously accepts integer strings
-
- Resolved
-