On Thu, 21 Dec 2023 21:51:10 GMT, Eamonn McManus <emcma...@openjdk.org> wrote:

> 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.

This pull request has now been integrated.

Changeset: 4fc6b0ff
Author:    Eamonn McManus <emcma...@openjdk.org>
URL:       
https://git.openjdk.org/jdk/commit/4fc6b0ffa4f771991a5ebd982b5133d2e364fdae
Stats:     28 lines in 2 files changed: 25 ins; 0 del; 3 mod

8068958: Timestamp.from(Instant) should throw when conversion is not possible

Reviewed-by: rgiulietti, rriggs

-------------

PR: https://git.openjdk.org/jdk/pull/17181

Reply via email to