JDK-8229337 : java.lang.Math class doc should be adjusted regarding -Exact methods
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 8
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-08-08
  • Updated: 2019-08-29
  • Resolved: 2019-08-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 14
14 b12Fixed
Related Reports
CSR :  
Relates :  
Description
The java.lang.Math class doc says,

 * In cases where the size is {@code int} or {@code long} and
 * overflow errors need to be detected, the methods {@code addExact},
 * {@code subtractExact}, {@code multiplyExact}, and {@code toIntExact}
 * throw an {@code ArithmeticException} when the results overflow.
 * For other arithmetic operations such as divide, absolute value,
 * increment by one, decrement by one, and negation, overflow occurs only with
 * a specific minimum or maximum value and should be checked against
 * the minimum or maximum as appropriate.

There are methods decrementExact(), incrementExact(), and negateExact() that throw exceptions on overflow. These should be included in the list of operations that can detect overflow. The advice about checking specific values still applies to divide and absolute value operations, though.
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/cf45b7945e4b User: dfuchs Date: 2019-08-23 17:42:21 +0000
23-08-2019

I will sponsor this change and push http://cr.openjdk.java.net/~dfuchs/jboes/8229337/webrev.01/ shortly as the CSR has been approved.
21-08-2019