-
Enhancement
-
Resolution: Duplicate
-
P4
-
None
-
8, 9
-
generic
-
generic
FULL PRODUCT VERSION :
1.8.0._131
ADDITIONAL OS VERSION INFORMATION :
windows 7 professional 64
A DESCRIPTION OF THE PROBLEM :
input:
public static void main(String[] args) {
System.out.println(Integer.valueOf("1_000"));
}
output:
Exception in thread "main" java.lang.NumberFormatException: For input string: "1_000"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at com.company.Main.main(Main.java:8)
Process finished with exit code 1
REGRESSION. Last worked in version 8u131
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
execute code:
public class Main {
//static
public static void main(String[] args) {
System.out.println(Integer.valueOf("1_000"));
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1000 in console output
ACTUAL -
Exception in thread "main" java.lang.NumberFormatException: For input string: "1_000"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at com.company.Main.main(Main.java:8)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NumberFormatException: For input string: "1_000"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at com.company.Main.main(Main.java:8)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Main {
//static
public static void main(String[] args) {
System.out.println(Integer.valueOf("1_000"));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
It is dont looks like fully support of "_" symbol,
you need modify Integer class (public static int parseInt) to remove underline symbol before parsing.
Its seems like you just forgot about this.
F.E: we store our number in config file, and is it like 1_000_000. and we need to write extra code to use it (if we reading string from config).
1.8.0._131
ADDITIONAL OS VERSION INFORMATION :
windows 7 professional 64
A DESCRIPTION OF THE PROBLEM :
input:
public static void main(String[] args) {
System.out.println(Integer.valueOf("1_000"));
}
output:
Exception in thread "main" java.lang.NumberFormatException: For input string: "1_000"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at com.company.Main.main(Main.java:8)
Process finished with exit code 1
REGRESSION. Last worked in version 8u131
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
execute code:
public class Main {
//static
public static void main(String[] args) {
System.out.println(Integer.valueOf("1_000"));
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1000 in console output
ACTUAL -
Exception in thread "main" java.lang.NumberFormatException: For input string: "1_000"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at com.company.Main.main(Main.java:8)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.NumberFormatException: For input string: "1_000"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at com.company.Main.main(Main.java:8)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Main {
//static
public static void main(String[] args) {
System.out.println(Integer.valueOf("1_000"));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
It is dont looks like fully support of "_" symbol,
you need modify Integer class (public static int parseInt) to remove underline symbol before parsing.
Its seems like you just forgot about this.
F.E: we store our number in config file, and is it like 1_000_000. and we need to write extra code to use it (if we reading string from config).
- duplicates
-
JDK-6863378 Project Coin: Consider library support for underscores in numbers and binary literals
-
- Closed
-