-
Notifications
You must be signed in to change notification settings - Fork 431
Description
(Reminder: Loom now has the ability to apply annotation changes from mapping sets such as yarn.)
I want to start a discussion on replacing Mojang's use of the @Nullable annotation with @UnknownNullability when the nullness of something frequently does not need to be checked. Here's what the @Nullable docs have to say about this situation:
By convention, this annotation applied only when the value should always be checked against
nullbecause the developer could do nothing to prevent null from happening. Otherwise, too eagerNullableusage could lead to too many false positives from static analysis tools.For example,
Map.get(Object key)should not be annotatedNullablebecause someone may have put not-null value in the map by this key and is expecting to find this value there ever since. It could be annotated as UnknownNullability or left unannotated.On the other hand, the
Reference.get()should be annotatedNullablebecause it returns null if object got collected which can happen at any time completely unexpectedly.
In our case, @UnknownNullability makes sense not only from a documentation perspective, but also to override the @FieldsAreNonnullByDefault annotation.
This issue applies to fields such as MinecraftClient.player, MinecraftClient.world, and others.