- Labels: --> report on spotbugs
- Status: open --> closed-rejected
In a project that doesn't explicitly uses any null-type anotations, FB is doing some smart analysis by looking at method's usage of their parameters to decide if the parameter is Nullable or not.
Using autobox-able types for parameters - long v Long, int v Integer, should be considered as a signal to the nullness of the param.
For example, consider
public boolean something(Integer n) {
return (n == 3);
}
public boolean someOtherThing(int k) {
return (k == 3);
}
Currently, the analysis determines that n is non-nullable (Because there's no null-check), and then warns when a call is made to something with a possibly-null value.
Instead, n should be considered Nullable, and there should be a warning about nullness when unboxing it (As if it were typed as @Nullable Integer n).
The reasoning here is that autobox types already have a mechanizm to describe nullablility (And projects that still use java <8 may find it hard to install relevant annotations).