Andrew John Hughes wrote: > > Interestingly, our parseInt Mauve test has this: > > // In JDK1.7, '+' is considered a valid character. > try > { > i = Integer.parseInt("+10"); > harness.check(true); > } > catch (NumberFormatException nfe) > { > harness.fail("Leading '+' does not throw NumberFormatException"); > } > > and indeed it does return 42 (so Classpath is still wrong returning > -42).
1.7 Javadoc: /** * Parses the string argument as a signed integer in the radix * specified by the second argument. The characters in the string * must all be digits of the specified radix (as determined by * whether [EMAIL PROTECTED] java.lang.Character#digit(char, int)} returns a * nonnegative value), except that the first character may be an * ASCII minus sign [EMAIL PROTECTED] '-'} (<code>'\u002D'</code>) to * indicate a negative value or an ASCII plus sign [EMAIL PROTECTED] '+'} * (<code>'\u002B'</code>) to indicate a positive value. The * resulting integer value is returned. * * <p>An exception of type [EMAIL PROTECTED] NumberFormatException} is * thrown if any of the following situations occurs: * <ul> * <li>The first argument is [EMAIL PROTECTED] null} or is a string of * length zero. * * <li>The radix is either smaller than * [EMAIL PROTECTED] java.lang.Character#MIN_RADIX} or * larger than [EMAIL PROTECTED] java.lang.Character#MAX_RADIX}. * * <li>Any character of the string is not a digit of the specified * radix, except that the first character may be a minus sign * [EMAIL PROTECTED] '-'} (<code>'\u002D'</code>) or plus sign * [EMAIL PROTECTED] '+'} (<code>'\u002B'</code>) provided that the * string is longer than length 1. * * <li>The value represented by the string is not a value of type * [EMAIL PROTECTED] int}. * </ul> * * <p>Examples: * <blockquote><pre> * parseInt("0", 10) returns 0 * parseInt("473", 10) returns 473 * parseInt("+42", 10) returns 42