Right, I see that now. Care must be exercised if this method is used on collections that do not comply with the general contract for {@code Collection}.
So, what does this mean? Are we catering to incorrect implementations? > On Feb 13, 2019, at 9:07 PM, Stuart Marks <stuart.ma...@oracle.com> wrote: > > On 2/13/19 7:22 PM, Alan Snyder wrote: >> If we take this route, how about changing the parameter type to Iterable? > > Won't work. Where I've ended up is that we need to iterate over "this" > collection and, for each element, call contains() on the parameter. The > AbstractCollection.removeAll() implementation does something like this: > > removeAll(Collection<?> c) { > for (Iterator<?> it = iterator(); it.hasNext();) { > if (c.contains(it.next())) { > it.remove(); > } > } > } > > Since we call contains() on the parameter, it has to be a Collection. > > s'marks >