Why @javax.annotation.CheckForNull is not included in "nullable" annotations" set by default?
Answered
As far as I know, when applied for a method, @javax.annotation.CheckForNull is meant to indicate that a returned value could be null in some cases and thus requires special handling. I know it could be added to "nullable annotations" as described on the help page: https://www.jetbrains.com/help/idea/2017.1/nullable-and-notnull-annotations.html . But why isn't it honored by default?
I'm not suggesting that @CheckForNull should be used on methods instead of @Nullable, the reason this question came up is that we have a project where @CheckForNull was used extensively (with FindBugs in mind), and we would like to make sure that developers using Idea get all the benefits of static checks for that project.
Please sign in to leave a comment.
We'll add it in the future updates by default (we just missed it). There is also another issue with @Nullable, it has been used incorrectly for years and there is a lot of code incorrectly annotated with @Nullable now, we don't know what to do with that.
See https://groups.google.com/forum/#!msg/jsr-305/mU-HqM4jwtk/Hoq1uPrykHMJ and https://static.javadoc.io/com.google.code.findbugs/jsr305/3.0.2/javax/annotation/Nullable.html.
So, @CheckForNull actually has to be used instead of @Nullable in most of the cases.
Related request: https://youtrack.jetbrains.com/issue/IDEA-19564.
Thanks for reporting, I've added this annotation to the defaults.