-
Bug
-
Resolution: Fixed
-
P3
-
1.1.1
-
1.2alpha
-
generic
-
solaris_2.5.1
-
Not verified
allan.jacobs@Eng 1997-03-21
The methods Integer.parseInt and Long.parseLong throw
ArithmeticExceptions when fed a radix of 0. The specification says
that they should throw NumberFormatExceptions when this happens.
See sections 20.7.18 and 20.8.18 .
algol% cat excps.java
class excps {
public static void main ( String[] argv ) {
int i;
try {
i = Integer.parseInt("11",0);
System.out.println( i );
}
catch ( NumberFormatException e ) {
System.out.println( "11,0: NumberFormatException" );
}
catch ( ArithmeticException e ) {
System.out.println( "11,0: ArithmeticException" );
}
long l;
try {
l = Long.parseLong("11",0);
System.out.println( l );
}
catch ( NumberFormatException e ) {
System.out.println( "11,0: NumberFormatException" );
}
catch ( ArithmeticException e ) {
System.out.println( "11,0: ArithmeticException" );
}
}
}
algol% javac excps.java
algol% java excps
11,0: ArithmeticException
11,0: ArithmeticException