8176425: Add radix indication in NumberFormatException message for Integer.decode

Reviewed-by: lancea
This commit is contained in:
Joe Darcy 2018-08-15 10:16:15 -07:00
parent b71faed5df
commit b0954bc7ab
4 changed files with 23 additions and 20 deletions

View file

@ -675,11 +675,11 @@ public final class Long extends Number implements Comparable<Long> {
negative = true;
limit = Long.MIN_VALUE;
} else if (firstChar != '+') {
throw NumberFormatException.forInputString(s);
throw NumberFormatException.forInputString(s, radix);
}
if (len == 1) { // Cannot have lone "+" or "-"
throw NumberFormatException.forInputString(s);
throw NumberFormatException.forInputString(s, radix);
}
i++;
}
@ -689,17 +689,17 @@ public final class Long extends Number implements Comparable<Long> {
// Accumulating negatively avoids surprises near MAX_VALUE
int digit = Character.digit(s.charAt(i++),radix);
if (digit < 0 || result < multmin) {
throw NumberFormatException.forInputString(s);
throw NumberFormatException.forInputString(s, radix);
}
result *= radix;
if (result < limit + digit) {
throw NumberFormatException.forInputString(s);
throw NumberFormatException.forInputString(s, radix);
}
result -= digit;
}
return negative ? result : -result;
} else {
throw NumberFormatException.forInputString(s);
throw NumberFormatException.forInputString(s, radix);
}
}
@ -945,7 +945,7 @@ public final class Long extends Number implements Comparable<Long> {
return result;
}
} else {
throw NumberFormatException.forInputString(s);
throw NumberFormatException.forInputString(s, radix);
}
}
@ -1063,7 +1063,7 @@ public final class Long extends Number implements Comparable<Long> {
return result;
}
} else {
throw NumberFormatException.forInputString("");
throw NumberFormatException.forInputString("", radix);
}
}