Consider such code
public void m1(String text) {
if(text == null)
text = "<empty>";
System.out.println(text.toLowerCase());
}
And this is a buggy version:
public void m1(String text) {
System.out.println(text.toLowerCase());
}
If null value passed, the NullPointerException may be thrown. I would like the static-analysis tool (e.g. FindBugs) to report this issue. Unsuccessfully the FindBugs (at least by default) requires me to specify @Nullable annotation explicitly.
public void m1(@Nullable String text) {
System.out.println(text.toLowerCase()); // FindBugs: text must be nonnull but is marked as nullable
}
The problem is that if I forget to annotate it, the bug will be missed!!!
How can I make the FindBugs (or any other free tool) to assume @Nullable by default?