Null-Restricted and Nullable Types
forax at univ-mlv.fr
forax at univ-mlv.fr
Wed Sep 4 14:06:29 UTC 2024
> From: "Brian Goetz" <brian.goetz at oracle.com>
> To: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "valhalla-spec-experts" <valhalla-spec-experts at openjdk.java.net>
> Sent: Wednesday, September 4, 2024 3:26:01 PM
> Subject: Re: Null-Restricted and Nullable Types
> Let's take a step back. Are you looking for *answers* in the short term (say, so
> you can answer someone elses questions), or are you looking to open the dialog
> about how we will expose nullness for purposes of generics migration? Because
> there are many, many pages of things to say about these questions, not all of
> which we have answers to, and this will significantly affect how we structure
> the discussion.
I'm opening the discussion. Those questions are like anchors to me, to try to avoid to go too deep into one of the rabbit holes.
Rémi
> On 9/4/2024 8:36 AM, [ mailto:forax at univ-mlv.fr | forax at univ-mlv.fr ] wrote:
>> Here are my questions:
>> 1/ Nullness of type variable
>> "Like other types, a type-variable type (that is, a use of a type variable) may
>> express nullness. T! is a null-restricted type, and T? is a nullable type."
>> - what does 'T' exactly mean ?
>> For me, there is the old 'T' which propagate the type but not propagate the
>> nullability and there is the new 'T' that propagate both the type and the
>> nullability of the type.
>> During the JVMLS, Dan Smith references them as 'T' and 'T*'.
>> 2/ If we agree that there are 4 different kinds: String/T, String?/T?,
>> String!/T! and T*, we now have the choice of several user facing models
>> - model 1, we let the user annotate using '!', '?' and '*'
>> - model 2, we have an opt-in mechanism that set type as '!' by default and type
>> variable as '*' by default.
>> - model 3, we only let user to annotate type variable declaration, type of
>> field, type of parameter types/return type, parametrized type (inside the angle
>> brackets) and cast, the rest is inferred
>> (this is the semantics of jspecify).
>> 3/ Nullness of wildcards
>> "A type variable declaration or wildcard may have nullness markers on its
>> bounds. A type may satisfy the bounds via nullness conversion, though, so again
>> these nullness markers are not strongly enforced, but may cause warnings."
>> => I see two questions here :
>> - unbounded wildcards, they are special because they represent a reified type,
>> so ? is nullable in List<?> because list.add(null) is valid at runtime, thus
>> List<?> is equivalent to List<? extends Object?>.
>> Do you agree ?
>> - super wildcard, the content of List<? super Foo!> may accept null because Foo?
>> is a super type of Foo!, so List<? super Foo!> is maybe nullable or maybe not,
>> so the content is neither a '!' nor a '?'. Do you agree ?
>> Rémi
>>> From: "Brian Goetz" [ mailto:brian.goetz at oracle.com | <brian.goetz at oracle.com> ]
>>> To: "Remi Forax" [ mailto:forax at univ-mlv.fr | <forax at univ-mlv.fr> ] ,
>>> "valhalla-spec-experts" [ mailto:valhalla-spec-experts at openjdk.java.net |
>>> <valhalla-spec-experts at openjdk.java.net> ]
>>> Sent: Tuesday, September 3, 2024 10:44:03 PM
>>> Subject: Re: Null-Restricted and Nullable Types
>>> There are many points that are not clear to us as well, but we will try to
>>> respond to your questions :)
>>> On 9/3/2024 4:41 PM, Remi Forax wrote:
>>>> Hello,
>>>> if everybody is okay with that i would like to discuss about Null-Restricted and
>>>> Nullable Types [1] tomorrow.
>>>> There are several points that are not clear to me, i will try to come up with a
>>>> list for tomorrow.
>>>> Rémi
>>>> [1] [ https://openjdk.org/jeps/8303099 | https://openjdk.org/jeps/8303099 ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-spec-experts/attachments/20240904/61243932/attachment.htm>
More information about the valhalla-spec-experts
mailing list