RFR: 8264161: BigDecimal#stripTrailingZeros can throw undocumented ArithmeticException

Fabian Meumertzheim github.com+4312191+fmeum at openjdk.java.net
Wed Apr 21 15:40:53 UTC 2021

Adds missing @throws declarations for ArithmeticException to the public
as well as the private helper functions
java.math.BigDecimal#createAndStripZerosToMatchScale(long, int, long)
java.math.BigDecimal#createAndStripZerosToMatchScale(BigInteger, int, long)

stripTrailingZeros calls one of the two helper functions, both of which
can repeatedly decrease the scale by 1 until it underflows. If it does,
the call to checkScale will result in an ArithmeticException (overflow).


Commit messages:
 - 8264161: ArithmeticException not declared for BigDecimal#stripTrailingZeros

Changes: https://git.openjdk.java.net/jdk/pull/3189/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3189&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8264161
  Stats: 3 lines in 1 file changed: 3 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3189.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3189/head:pull/3189

PR: https://git.openjdk.java.net/jdk/pull/3189

More information about the core-libs-dev mailing list