[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jdt-dev] Null Annotations / EEA
|
Good evening,
you may know that there is a project named LastNPE that provides EEA for a bunch of libraries.
Recently a discussion was brought up how to correctly model the annotations for methods like Optional.orElse or Map.computeIfAbsent
In both cases we need to make the return value @Nullable, because the argument is allowed to be null and in that case the return value is also null.
However this creates the need for a lot of unnecessary null-checks, if the value is guaranteed to be non-null, e.g. if used like Map.computeIfAbsent(key, k -> new Foo()).
So what we would need to have is something to express „same nullness like argument“ (like @PolyNull in checkerframework) or the option to have two annotations, one for a @Nullable argument and one for a @NonNull argument. Both need support in the compiler.
That‘s why I‘m writing here. I couldn’t find a discussion for that. WDYT?
Jan (GitHub: J-N-K)