-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
8, 11, 17
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
The method specification for contains() in java.util.TreeSet reads:
More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).
However, this is not how TreeSet is implemented. Based on my testing, TreeSet uses the comparable to determine equality, instead of Objects.equals().
Although this is noted in the class specification of TreeSet, it is still VERY confusing for developers and thus should be corrected by revising the method spec for contains().
FREQUENCY : always
The method specification for contains() in java.util.TreeSet reads:
More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).
However, this is not how TreeSet is implemented. Based on my testing, TreeSet uses the comparable to determine equality, instead of Objects.equals().
Although this is noted in the class specification of TreeSet, it is still VERY confusing for developers and thus should be corrected by revising the method spec for contains().
FREQUENCY : always
- relates to
-
JDK-8181579 Inconsistency between API documentation and TreeSet.add(...) behaviour
-
- Open
-
-
JDK-8278269 ConcurrentSkipListSet::add works not based on equality
-
- Open
-