<p dir="ltr">And we think there might be a few more things although I'm not sure they're types that would opt in to this. There are several methods that I can "think" of that will throw errors if you pass them nulls. For example Optional.of would make no sense not to have its parameter as non null. Although maybe they would opt for that so people can catch the exception which I find ridiculous</p>
<br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Jan 10, 2025, 8:03 AM Jean-Noël Rouvignac <<a href="mailto:jean-noel.rouvignac@pingidentity.com">jean-noel.rouvignac@pingidentity.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>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.<br></div>Future added types may opt into being null-restricted value types from the get go.<br><div><div>It means`null` can be used today with confidence it won't go away in the future.<br><br>> 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.<br><br></div><div>That's true.<br></div><div>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.<br><br></div><div>Thanks all!<br></div></div></div></div>
<br>
<i style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background:rgb(255,255,255);font-family:proxima-nova-zendesk,system-ui,-apple-system,system-ui,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",Arial,sans-serif;color:rgb(85,85,85)"><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background:transparent;font-family:proxima-nova-zendesk,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",Arial,sans-serif;font-weight:600"><font size="2">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.</font></span></i></blockquote></div>