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

SortedList has wrong javadoc documentation

XMLWordPrintable

      The SortedList javadoc states that if you create a SortedList without specifying a comparator the natural ordering of the element is used.

      This is not the actual behavior, the behavior was changed in RT-30831 without updating the javadoc. The current behavior is that the list is unordered if no comparator was explicitly set.


      IMHO the orginal behavior was much better: natural ordering has always been the default for sorting in Java and all Java developers not knowing about this exception to the rule will write buggy code.
      Moreover if you look at the following code:

          ObservableList<Event> events = FXCollections.observableArrayList();
          SortedList<Event> sortedEvents = events.sorted();

      The sortedEvents list is unordered, which is not what you expect!

            msladecek Martin Sládeček
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: