1
有沒有什麼辦法讓FindBugs檢查並警告我,如果CheckForNull註釋存在於類中方法的實現中,而不是接口中方法的聲明中?類和接口上的FindBugs和CheckForNull
import javax.annotation.CheckForNull;
interface Foo {
public String getBar();
}
class FooImpl implements Foo {
@CheckForNull
@Override
public String getBar() {
return null;
}
}
public class FindBugsDemo {
public static void main(String[] args) {
Foo foo = new FooImpl();
System.out.println(foo.getBar().length());
}
}
我剛剛發現我的應用程序中的錯誤,由於不是由FindBugs的發現,因爲CheckForNull僅出現在FooImpl,但不是富失蹤空檢查,我不希望發現所有其他手動解決此問題的位置。