Name: saf@russia Date: 08/26/96
This bug was found by St.Petersburg Java SQE team (by Alexander Kuzmin).
The java.lang.Integer.parseInt(String, int) method does not work properly
with the first parameter according to the Java language specification.
The Java Language specification
(Pre-Release Version 1.0, Draft 5.2 - July 3, 1996)
says the following (please see item 20.7.18):
_____
20.7.18 public static int parseInt(String s, int radix)
throws NumberFormatException.
An exception of type NumberFormatException is thrown if any
of the following situations occurs:
The first argument is null or is a string of length zero.
The radix is either smaller than Character.MIN_RADIX
or larger than Character.MAX_RADIX.
The integer value represented by the string is not a value of
type int.
parseInt("2147483648", 10) throws a NumberFormatException.
_____
So Integer.parseInt(String,int) does not throw NumberFormatException,
if the first parameter is a string that denotes a very long integer
(more than 4 bytes in binary form, if converted to an integer).From
this viewpoint, the following methods do not work correctly :
Integer(String)
valueOf(String,int )
getInteger(String,String)
_______________________Example of parseInt()_________________________
//Test IntegerPs2 Test parseInt(String str) where str is too big
try {
val = Integer.parseInt("80ffffffffff",16);
} catch ( NumberFormatException e ) {
return Status.passed( "IntegerPs2 Ok" ); // newer catch
}
return Status.failed( "IntegerPs2 Exception not thrown" );
// This exception will not be thrown.
_____________________________________________________________________