Nullity (was: User model stacking: current status)

Mariell Hoversholm mariell.hoversholm at paf.com
Wed May 11 13:32:00 UTC 2022


I would also like to bring up the fact that this could already be possible
in the long term (though not as baked into the language as the idea at
hand). Currently, the ecosystem has many different libraries for nullity
annotations; this ranges from JetBrains Annotations to CheckerQual (with
annotation processing to find bugs; same exists with NullAway and Google
Find Bugs) to Spring/Quarkus.

While we do not have the language feature, code is commonly annotated with
annotations instead, e.g.:

    @NonNull String getSomeValue();
    @Nullable Integer fetchSomething(@Nullable String reference);

and with tools such as lombok, we can even get automatic null-checks on
these annotations. This has been underway for a while now (at least a few
years). However, I think only recently (~1-2 yrs ago) did proper large
projects pick them up (referring to Spring and Guava). I do not see much of
a reason for this to change, given it increases safety in code, but we may
all be surprised there.

That being said, I fully understand the implications any such changes would
have on the language: it would be an official, set-in-stone solution to an
issue we haven't seen culminate for a significant time period. Different
languages, libraries, and tools come with different solutions constantly,
featuring different helpers: the Elvis operator, `?:` (Kotlin, Groovy) or
`??` (C#) is a big one, along with the null-safe accessor, `?.`.
Perhaps it would be a good idea to bring up a separate language topic for
these solutions as serious ideas, as opposed to wild speculation?

My apologies if anything is incoherent; I've had a full day already :-).
Cheers.

On Wed, 11 May 2022 at 14:53, Brian Goetz <brian.goetz at oracle.com> wrote:

>
>
> > I'm not sure of how much help I am to your gauging interest, but hope
> > it could,
> > at the very least, be a small indication of how users of other
> > languages may
> > find the ideas brought up.
>
> Oh, trust me, we're well aware that millions of Java developers would
> jump for joy -- at least, initially -- if we pulled this trigger.
>
> My concern is what they do _after_ that.  Giving people something that
> looks superficially like something they think they like from another
> language does not always create lasting joy.  What happens in the first
> five minutes is much less important than what happens in the following
> ten years.
>
>
>


More information about the valhalla-spec-observers mailing list