8318646: Integer#parseInt("") throws empty NumberFormatException message

Reviewed-by: redestad, alanb, bpb, darcy, uschindler
This commit is contained in:
Raffaello Giulietti 2023-10-24 10:20:26 +00:00
parent 3f446c5156
commit 9bfa082970
2 changed files with 6 additions and 6 deletions

View file

@ -592,7 +592,7 @@ public final class Long extends Number
int len = s.length();
if (len == 0) {
throw new NumberFormatException("");
throw NumberFormatException.forInputString("", radix);
}
int digit = ~0xFF;
int i = 0;
@ -667,7 +667,7 @@ public final class Long extends Number
* and by not updating i anywhere else.
*/
if (beginIndex == endIndex) {
throw new NumberFormatException("");
throw NumberFormatException.forInputString("", radix);
}
int digit = ~0xFF; // ~0xFF means firstChar char is sign
int i = beginIndex;
@ -864,7 +864,7 @@ public final class Long extends Number
* and by not updating i anywhere else.
*/
if (beginIndex == endIndex) {
throw new NumberFormatException("");
throw NumberFormatException.forInputString("", radix);
}
int i = beginIndex;
char firstChar = s.charAt(i++);