Consider this code
public void m1(String text) { if(text == null) text = "<empty>"; System.out.println(text.toLowerCase()); }
And this is a mistake:
public void m1(String text) { System.out.println(text.toLowerCase()); }
If null is passed, a NullPointerException may be thrown. I would like a static analysis tool (e.g. FindBugs) to report this issue. Unsuccessfully FindBugs (at least by default) requires me to explicitly provide @Nullable annotation.
public void m1(@Nullable String text) { System.out.println(text.toLowerCase());
The problem is that if I forget to annotate it, the error will be missed !!!
How can I make FindBugs (or any other free tool) take @Nullable by default?
source share