On Mon, 29 Sep 2025 13:55:35 GMT, Pavel Rappo <[email protected]> wrote:

> We recently [discussed] the possibility of introducing saturating arithmetic 
> for deadline computation. Consider this PR as a starting point. Once we agree 
> on the implementation, I'll file a CSR.
> 
> I created a method in `Instant` to add `Duration`. One could argue that the 
> proper way would be to go all the way and create a method in `Temporal` to 
> add `TemporalAmount`. Or maybe even expand the functionality, and create an 
> additional method in `Temporal` to subtract `TemporalAmount`.
> 
> My current thinking is that if we were to do that, there would be a lot of 
> expensive, unused code. Saturating logic seems to be only useful for 
> `Instant` and `Duration`.
> 
> Even if we decide to extend `Temporal` to add/subtract `TemporalAmount`, it 
> could always be done later. From the perspective of `Instant`, 
> `plus(TemporalAmount)` will be just an overload of `plus(Duration)`.
> 
> [discussed]: 
> https://mail.openjdk.org/pipermail/core-libs-dev/2025-September/151098.html

This pull request has now been integrated.

Changeset: 2758c6fd
Author:    Pavel Rappo <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/2758c6fda2f774d98ef0c24535a7f7e9fc722379
Stats:     104 lines in 2 files changed: 104 ins; 0 del; 0 mod

8368856: Add a method that performs saturating addition of a Duration to an 
Instant

Reviewed-by: naoto, rriggs, scolebourne

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

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

Reply via email to