By default, the Java Collections Framework allows implementations of
java.util.List to support the
However, using null entries in collections is quite rare in practice, so keeping this behavior when Null Analysis is enabled would produce lots of unwanted errors and would force to explicitly write lots of unwanted assertions in most cases.
Therefore, we decided to disallow the use of null entries in collections for the benefit of Null Analysis. That’s why
java.util.List.add(Object) requires a non null object when Null Analysis is enabled (the
java.util package is marked with the
However, the implementation is left unchanged, so you can still use null entries by relaxing the Null Analysis rules of the project using it.