Current thinking about the future nullability of java.time.Duration
Jean-Noël Rouvignac
jean-noel.rouvignac at pingidentity.com
Fri Jan 10 13:02:36 UTC 2025
After your comments, I realize that, except primitive types, no type in the
JDK will opt-in to become a null-restricted value class type because this
would be an incompatible change.
Future added types may opt into being null-restricted value types from the
get go.
It means`null` can be used today with confidence it won't go away in the
future.
> As currently specified, there is no clean Duration value that could be
used as a sentinel (alternative to null) except in some application
specific use.
That's true.
I currently have a `public static final Duration UNLIMITED =
Duration.ofSeconds(Long.MAX_VALUE);`, but this is not really a sentinel,
and any other `Duration.ofSeconds(Long.MAX_VALUE)` is equal to it. So it's
not a problem.
Thanks all!
--
_CONFIDENTIALITY NOTICE: This email may contain confidential and privileged
material for the sole use of the intended recipient(s). Any review, use,
distribution or disclosure by others is strictly prohibited. If you have
received this communication in error, please notify the sender immediately
by e-mail and delete the message and any file attachments from your
computer. Thank you._
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-dev/attachments/20250110/6fcca9f7/attachment.htm>
More information about the valhalla-dev
mailing list