@NonNull and @Nullable annotations on parameters and return types
See original GitHub issueI think adding @NonNull
and @Nullable
annotations to the source code would be very helpful documentation. It would also allow better Kotlin interoperability, since the Kotlin compiler can recognize these annotations. There are already a few places where the javadoc indicates that a parameter may be null but it’s far from being widespread.
For example the Batch in draw method and the events in event listeners are never null. These are obvious, but there are many cases where all the usages of a method but be looked at to know whether the parameter type is nullable or not. Kotlin also marks the Color
and Interpolation
constants as potentially nullable.
I understand that adding these annotations to every public method would be a very big undertaking, but I think it would prove to be very useful.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:7 (7 by maintainers)
Top GitHub Comments
I have recently added them to Spigot API (for Minecaft server mods). It took about 30 hours, but I did find some bugs and I think that their API is now better for it. I think that this would be a good-first-issue (especially if it is split up into multiple smaller PRs), but someone (=core contributor) must first decide, which annotations should be used, as there is a lot of options, and all have their pros and cons. I outlined some of the options in the issue linked above, and ended up using the Jetbrains flavored ones, but libGDX may have a different needs and decide differently.
Can this issue be closed seeing that https://github.com/libgdx/libgdx/pull/5812 has been merged in?