Current thinking about the future nullability of java.time.Duration
Glavo
zjx001202 at gmail.com
Sun Dec 29 19:48:39 UTC 2024
Hi Jean-Noël,
>From what I understand, the null-restricted types are use-site specified,
which means that `Duration` is not null-restricted, but `Duration!` is
null-restricted, even though it is a value class.
It is also worth noting that null-restricted types are not a requirement
for flattening value objects.
For a variable of a nullable value type, Valhalla may use a "null channel"
to distinguish between null and non-null values.
The null channel could be a boolean variable or something else, you can
read this article[1] to learn more about it.
Glavo
[1]: https://cr.openjdk.org/~jrose/values/flattened-values.html
On Mon, Dec 30, 2024 at 12:49 AM Jean-Noël Rouvignac <
jean-noel.rouvignac at pingidentity.com> wrote:
> Hello,
>
> I have a use case for configuration objects where I would like to
> use java.time.Duration to represent time intervals, timeouts, delays, etc.
> for example.
>
> In these configuration objects, sometimes users may not provide a value,
> and the configuration framework does not have a default value for it
> either. This is to be interpreted as "disable the feature" or "let the
> library decide". For this specific case, I was considering returning `null`
> to mean "disable the feature" or "let the library decide".
>
> java.time.Duration being marked as a value based class, I wanted to
> confirm that using `null` will not force significant rework in the future?
> i.e. java.time.Duration will not opt-in to become a null-restricted value
> class type (https://openjdk.org/jeps/8316779).
>
> Thanks a lot, and thanks for the huge work on Valhalla. Good luck for
> bringing it into mainline Java !
>
> Jean-Noël
>
> *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/20241230/7020eb51/attachment-0001.htm>
More information about the valhalla-dev
mailing list