FULL PRODUCT VERSION :
openjdk version "1.8.0_40-internal"
OpenJDK Runtime Environment (build 1.8.0_40-internal-b27)
OpenJDK 64-Bit Server VM (build 25.40-b25, mixed mode)
A DESCRIPTION OF THE PROBLEM :
According to the documentation, java.lang.Long.parseUnsignedLong static method is supposed to throw NumberFormatException on strings representing values greater than 2**64-1. However, sometimes numeric overflow is not detected. Example:
Long.parseUnsignedLong("46116860184273879040")
On my machine, this expression is evaluated without throwing any exceptions, and the result is -9223372036854775808L (which is equal to 9223372036854775808 when interpreted as unsigned).
Expected behavior: evaluation of this expression should result in NumberFormatException being thrown.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) {
System.out.println(Long.toUnsignedString(Long.parseUnsignedLong("46116860184273879040")));
}
}
---------- END SOURCE ----------