score:1

Accepted answer

it is possible to use @nonnullbydefault with inherited, unconstrained classes, but an explicit @nullable constraint must be applied to method parameters of any method which is overriden. this is because the default, unconstrained behavior for java, is to allow nulls.

the confusion here is a result of a misplacement of the @nullable annotation. the placement in the original question suggests that the array contents should not be null rather than the array itself.

there is a bug but it's not with the annotation; it's a result of eclipse (as of 4.6) placing the annotation in the wrong location with the quick fix feature, reinforcing an erroneous placement which does not correct the error.

the correct placement for arrays is:

public void somemethod(
   string @nullable[] a)
{

}

Related Query

More Query from same tag