What the Duration of negative Infinity mean?

Martin Sladecek martin.sladecek at oracle.com
Fri Feb 1 00:58:55 PST 2013


Scott is right here, we shouldn't check for wrong values in Duration, 
but rather in the API that accepts Duration.

This means negative infinity is just negative infinity. It's up to the 
API how it will treated, we don't need to disallow it or have some 
special name for it. But as for all of our API so far, all negative 
values are illegal, so is the negative infinity.

-Martin

On 02/01/2013 03:07 AM, Scott Palmer wrote:
> On 2013-01-31, at 12:42 PM, Martin Sladecek <martin.sladecek at oracle.com> wrote:
>
>> The other option is not to throw the exception and keep the Duration values above zero. If a > b, then b.subtract(a) will result in 0.
> This may just be an intermediate value that is later added as in Richard's example.
>
>
> But, I think this is over complicating things.  What exactly are we trying to accomplish?  A negative duration doesn't make sense as a *final value*, so in the context of setting the actual duration to use for an interval, I think it makes sense to disallow negative values, even though the Duration object is allowed to hold them.  It's no different than an API that takes integers where you must supply a positive value for the API to accept your input.
>
> The SchedulerService can't use a negative duration unless you've incorporated time travel into it.
>
> For a general Duration, POSITIVE_INFINITY can map to isIndefinite, and NEGATIVE_INFINITY can be illegal or indefinite, either makes sense.
>
> Scott
>



More information about the openjfx-dev mailing list