> Multiplying with `*` never produces `ArithmeticException`, so the catch in > the existing code is never triggered. `Math.multiplyExact` does produce > `ArithmeticException` if the multiplication overflows. So we can use that, > and rethrow `IllegalArgumentException` as the specification says. > > There is a small compatibility risk, in that code may have been relying on > the previous silent overflow, and will now get an exception. But an exception > is surely better than the nonsense results that overflow produces. > > Thanks to Kurt Kluever for the test cases.
Eamonn McManus has updated the pull request incrementally with one additional commit since the last revision: Address review comments about the new test. ------------- Changes: - all: https://git.openjdk.org/jdk/pull/17181/files - new: https://git.openjdk.org/jdk/pull/17181/files/32b3de53..8f2e929c Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=17181&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=17181&range=00-01 Stats: 20 lines in 1 file changed: 4 ins; 8 del; 8 mod Patch: https://git.openjdk.org/jdk/pull/17181.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/17181/head:pull/17181 PR: https://git.openjdk.org/jdk/pull/17181