Skip to content

Commit

Permalink
8318646: Integer#parseInt("") throws empty NumberFormatException message
Browse files Browse the repository at this point in the history
Reviewed-by: redestad, alanb, bpb, darcy, uschindler
  • Loading branch information
rgiulietti committed Oct 24, 2023
1 parent 3f446c5 commit 9bfa082
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/lang/Integer.java
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public static int parseInt(String s, int radix)

int len = s.length();
if (len == 0) {
throw new NumberFormatException("");
throw NumberFormatException.forInputString("", radix);
}
int digit = ~0xFF;
int i = 0;
Expand Down Expand Up @@ -637,7 +637,7 @@ public static int parseInt(CharSequence s, int beginIndex, int endIndex, int rad
* and by not updating i anywhere else.
*/
if (beginIndex == endIndex) {
throw new NumberFormatException("");
throw NumberFormatException.forInputString("", radix);
}
int digit = ~0xFF;
int i = beginIndex;
Expand Down Expand Up @@ -827,7 +827,7 @@ public static int parseUnsignedInt(CharSequence s, int beginIndex, int endIndex,
* 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++);
Expand Down
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/lang/Long.java
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ public static long parseLong(String s, int radix)

int len = s.length();
if (len == 0) {
throw new NumberFormatException("");
throw NumberFormatException.forInputString("", radix);
}
int digit = ~0xFF;
int i = 0;
Expand Down Expand Up @@ -667,7 +667,7 @@ public static long parseLong(CharSequence s, int beginIndex, int endIndex, int r
* 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;
Expand Down Expand Up @@ -864,7 +864,7 @@ public static long parseUnsignedLong(CharSequence s, int beginIndex, int endInde
* 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++);
Expand Down

1 comment on commit 9bfa082

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.