Long upper limit value
Open
bug
- Dominant language
- Java
- Stars
- 24.2k
- Forks
- 4.5k
- Avg merge
- 6d 4h
- Merged PRs (30d)
- 12
Description
Use Gson
```
Gson gson = new Gson();
Long a = gson.fromJson("9223372036854775808", Long.class);
System.out.println(a);
=> 9223372036854775807
```
Use JsonPrimitive
```
var jp = new JsonPrimitive("9223372036854775808");
Long b = jp.getAsLong();
System.out.println(b);
=> java.lang.NumberFormatException: For input string: "9223372036854775808"
```
Use Long.valueOf
```
Long c = Long.valueOf("9223372036854775808");
System.out.println(c);
=> java.lang.NumberFormatException: For input string: "9223372036854775808"
```
Why is there no error in Gson?
Is this a bug? Or is it a specification?
I want an error to occur.
Contributor guide
Assessment
This issue has not been assessed yet.