I want to use Jetbrains @Nullable/@NotNull Annotations in my project.
I have a class with a @NotNull field. The constructor naturally does not accept null
but throws an exception instead. Of course the parameter of this constructor is also be annotated with @NotNull.
Why does IntelliJ IDEA complain about the null-check? The documentation states:
An element annotated with NotNull claims null value is forbidden to return (for methods), pass to (parameters) and hold (local variables and fields).
But I still have to check for null-values at runtime in case the build system does not understand the Annotation and accepts a statement like new Car(null)
. Am I wrong?