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