mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8176425: Add radix indication in NumberFormatException message for Integer.decode
Reviewed-by: lancea
This commit is contained in:
parent
b71faed5df
commit
b0954bc7ab
4 changed files with 23 additions and 20 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue