Search code examples
javaguavafindbugschecker-framework

How to use Checker Framework annotations with Findbugs?


I am migrating codebase to Guava 26.0-jre from 18.0. Static code checks are processed by Findbugs (3.0.0). It turns out that Guava migrated from JSR305 to Checker Framework.

Therefore, existing code like this:

com.google.common.collect.Iterables.getFirst(someCollection, null);

ends up with an error:

[INFO] Null passed for non-null parameter of com.google.common.collect.Iterables.getFirst(Iterable, Object)

My question is: how to force Findbugs to understand Checker Framework's annotations? Is there any way to do this smoothly? I have googled for some plugins for Findbugs but found nothing.


Solution

  • FindBugs cannot do this. FindBugs is also an abandoned project. You might want to consider its successor SpotBugs. SpotBugs seems to have support for Checker Framework annotations.