Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8055697

(spec) TreeSet.contains documentation is incorrect

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 7
    • core-libs

      A DESCRIPTION OF THE PROBLEM :
      Documention of TreeSet.contains(Object o) states that this method returns true if this set contains an element e such that (o==null ? e==null : o.equals(e)). It is not true, because:

      If o == null then NullPointerException is thrown, see @Throws;

      If this set uses natural ordering then this method returns true if this set contains an element e such that (((Comparable)o).compareTo(e) == 0);

      If this method uses comparator then it returns true if this set contains an element e such that (comparator.compare(o, e) == 0).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that (o==null ? e==null : o.equals(e)).
      ACTUAL -
      Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that (((Comparable)o).compareTo(e) == 0) if this this set uses natural ordering or (comparator.compare(o, e) == 0) if this set uses comparator.

      URL OF FAULTY DOCUMENTATION :
      http://docs.oracle.com/javase/7/docs/api/java/util/TreeSet.html#contains(java.lang.Object)

            Unassigned Unassigned
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported: