RFR: 8068958: Timestamp.from(Instant) should throw when conversion is not possible [v2]

Raffaello Giulietti rgiulietti at openjdk.org
Fri Dec 22 23:28:47 UTC 2023


On Fri, 22 Dec 2023 22:55:09 GMT, Eamonn McManus <emcmanus at 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.
>
> Eamonn McManus has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Address review comments about the new test.

Don't forget to update the copyright years in both files, please ;-)

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

PR Comment: https://git.openjdk.org/jdk/pull/17181#issuecomment-1868127480


More information about the core-libs-dev mailing list