Is JLS Wrong?
No, JLS is specific - to distinguish between an int variable and an "int literal", that is, a decimal literal of type int.
The range of the int variable is -2,147,483,648,2,147,483,647 (i.e. - (2 ^ 31) .. 2 ^ 31-1)
The largest decimal literal that the compiler will parse in Java code and use in the int context is 2,147,483,648, but it can only be used as an operand of the unary operator "-", i.e. you can only use it in only one way - to build the most negative decimal value that int can contain: -22147483648 .
In this JLS section, you mention section 3.10.1 Integer literals , which say:
The largest decimal literal of type int is 2147483648 (2 ^ 31).
also says a few lines later:
This is a compile-time error if the decimal literal of type int is greater than 2147483648 (2 ^ 31), or if the decimal literal 2147483648 appears anywhere other than the operand of the unary minus operator.
source share