I currently use
@DefaultAnnotation(NonNull.class)
package jobs;
import edu.umd.cs.findbugs.annotations.DefaultAnnotation;
import edu.umd.cs.findbugs.annotations.NonNull;
however the annotation @edu.umd.cs.findbugs.annotations.DefaultAnnotation is deprecated:
http://findbugs.sourceforge.net/api/edu/umd/cs/findbugs/annotations/DefaultAnnotation.html
They propose to use javax.annotation.ParametersAreNonnullByDefault
However, DefaultAnnotation not only targets parameters, but also fields and methods.
So, what is the javax.annotation alternative for setting fields and methods to Nonnull by default?
As far as I know there is none. Wanting the same thing, I copied the source for
ParametersAreNonnullByDefaultinto my ownFieldsAreNonnullByDefaultandMethodsAreNonnullByDefaultand changed the@TypeQualifierDefaultvalues to match (FIELDandMETHODrespective). FindBugs picks up these new annotations perfectly.Here’s a sample for
FieldsAreNonnullByDefault: