@Nonnull
, @CheckForNull
, or @Nullable
detected on primitive declaration JAVA-W1063Primitive types can't be null
. Marking primitive parameters, return values, or fields with CheckForNull
, Nullable
,
or NonNull
is useless and only adds confusion. These annotations should be removed to improve readability of code.
class Example {
@Nullable private int field = 10;
@CheckForNull
public int method(@NonNull int param) {
// ...some code
}
}
Remove these annotations from primitive declarations.
class Example {
private int field = 10;
public int method(int param) {
// ...some code
}
}
}
@Nonnull
@CheckForNull
@Nullable