RFR: 8264161: BigDecimal#stripTrailingZeros can throw undocumented ArithmeticException

Brian Burkhalter brian.burkhalter at oracle.com
Wed Apr 21 16:23:05 UTC 2021


On Apr 21, 2021, at 9:14 AM, Fabian Meumertzheim <github.com+4312191+fmeum at openjdk.java.net<mailto:github.com+4312191+fmeum at openjdk.java.net>> wrote:

On Thu, 25 Mar 2021 08:19:24 GMT, Fabian Meumertzheim <github.com+4312191+fmeum at openjdk.org<mailto:github.com+4312191+fmeum at openjdk.org>> wrote:

Adds missing @throws declarations for ArithmeticException to the public
function
java.math.BigDecimal#stripTrailingZeros
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).

Please note the issue [8264161](https://bugs.openjdk.java.net/browse/JDK-8264161) has already been addressed by:
#3204

@RogerRiggs The fix in #3204 remains incomplete as it does not update the `@throws` declarations. I could open a new bug for that, but unfortunately the form at https://bugreport.java.com/bugreport/start_form.do appears to be down: There is no server response when clicking "Submit", the request to https://bugreport.java.com/bugreport/submit_start.do just hangs forever.

There is in fact some system maintenance which should be completed this morning, Pacific Time. After that a new issue for this should be filed as we cannot reuse issue IDs.

Thanks.


More information about the core-libs-dev mailing list