Behavior change in most Collection.removeAll and Collection.retainAll implementations

Prior to Java SE 8, most implementations of Collection.removeAll(Collection) and retainAll(Collection) return false and silently ignore a null parameter if the collection itself was empty. In Java 8, all collection implementations throw a NullPointerException if null is provided as a parameter.

To identify where these exceptions might occur, this rule flags the invocation of the removeAll(Collection) and the retainAll(Collection) methods in the following implementations and interfaces so that you can evaluate your logic to avoid an unexpected NullPointerException.

The retainAll(Collection) method is flagged for the following implementations. For these, the removeAll(Collection) method already throws a NullPointerExceptions in Java 6 and Java 7.

Java 8 does not introduce a behavior change for the following collection implementations, so they are not flagged by this rule:

For additional information about the java.util.Collection interface and its implementations, see the Interface java.util.Collection Java documentation.