Architectury API (Fabric/Forge/NeoForge)

Architectury API (Fabric/Forge/NeoForge)

158M Downloads

[Request] Add @Notnull and @Nullable annotations.

CubeSugarCheese opened this issue ยท 3 comments

commented

I am a kotlin developer.
When I using architectury-api, I found my IDE remind me to declare the type explicitly. I think @Notnull and @Nullable annotations are useful.
But I found #216 , it said

Remove All @NotNull

I want to know why. I think those annotations are useful. So why not add those to code?

commented

From a Java perspective, NotNull is purely spam since we typically assume a type is only null if it's Nullable. It's extra work for not much benefit (note that even in Kotlin, you can assume that ! types aren't null).

It was also done inconsistently in Arch code - we didn't have it everywhere where it should've been.

commented

Yep, architectury code is just annotated with @nullable where applicable now, you can assume that types without nullable is not nullable

commented

Like Juuz said, it is usually safe to assume a Java platform type T! is not null within both Architectury and Minecraft code unless it is explicitly annotated as @Nullable (in which case Kotlin will correctly pick that up anyways)

We will likely not be adding explicit NotNull annotations everywhere, considering it's mostly just ... visual clutter within the source code and because of the convention mentioned above applying on the Java side as well