A reference to null
should never be dereferenced/accessed. Doing so will cause a NullPointerException
to be thrown. At
best, such an exception will cause abrupt program termination. At worst, it could expose debugging information that would be useful to an attacker, or
it could allow an attacker to bypass security measures.
Note that when they are present, this rule takes advantage of nullability annotations, like @CheckForNull
or @Nonnull
,
defined in JSR-305 to understand which values can be null or not. @Nonnull
will be
ignored if used on the parameter of the equals
method, which by contract should always work with null.