My question is a follow-up to this one.
In past versions of FindBugs, it was possible to use @DefaultAnnotation(Nonnull.class)
or @DefaultAnnotationFo
I had a similar question, and found that the following seems to work with findbugs (2.0.1-rc2)
Create a java file with the following annotation definition
@Nonnull
@TypeQualifierDefault(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface FieldsAreNonNullByDefault
{
}
similarly, to enforce that all return values from a method are non-null
@Nonnull
@TypeQualifierDefault(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ReturnTypesAreNonNullByDefault
{
}
and then annotate the package as normal.
I used the following for my tests (package-info.java)
@javax.annotation.ParametersAreNonnullByDefault
@com.habit.lib.lang.FieldsAreNonNullByDefault
@com.habit.lib.lang.ReturnTypesAreNonNullByDefault
package com.mypackagename.subpkg;