I have a class which is annotated with ParametersAreNonnullByDefault
javax annotation. But its constructor and methods accept null parameters and don't throw NullPointerException
.
@ParametersAreNonnullByDefault
class MyClass {
private Integer intField;
public MyClass(Integer intField) {
this.intField = intField;
}
public Integer someMethod(Integer a) {
return a;
}
}
The following lines of code do not throw NullPointerException as I would expect:
MyClass obj = new MyClass(null);
obj.someMethod(null);
As per the documentation, "This annotation can be applied to a package, class or method to indicate that the method parameters in that element are nonnull by default". Where/when is the null check being made for method parameters with this annotation?