RFR [15] 6394757: rev2: AbstractSet.removeAll semantics are surprisingly dependent on relative sizes

Alan Snyder javalists at cbfiddle.com
Tue May 12 23:03:46 UTC 2020


You must have misunderstood. Even so, a snarky answer is uncalled for.

The specification of Object.equals() is violated by the example, but that outcome would be *required* by your version of the specification of Set.equals().

Do you really think that the specification of Object.equals() is unimportant? Lots of code relies on it.



> On May 12, 2020, at 2:37 PM, Stuart Marks <stuart.marks at oracle.com> wrote:
> 
> 
> 
>>> The containsAll() and equals() methods both use the membership contract of the receiver, not the argument. Unfortunately, the equals() specification says,
>>> 
>>>    Returns true if the specified object is also a set, the two sets have the
>>>    same size, and every member of the specified set is contained in this set
>>>    (or equivalently, every member of this set is contained in the specified
>>>    set).
>>> 
>>> As should be clear from this discussion, the "equivalently" clause is incorrect -- another spec bug.
>> Changing Set.equals() in this way would make Set inconsistent with Object.
>> Do you really think that is a good idea?
> 
>    [example of asymmetry of equals]
> 
> Your example illustrates that the "equivalently" clause is incorrect. I prefer specifications to have fewer incorrect statements.
> 
> s'marks
> 



More information about the core-libs-dev mailing list