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

MultipleSelectionModelBase::clearSelection() is incorrect

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8u60
    • 8u31
    • javafx
    • None

      Code snippet from MultipleSelectionModelBase.java, function public void clearSelection() , line 630:

                  List<Integer> removed = new AbstractList<Integer>() {
                      final BitSet clone = (BitSet) selectedIndices.clone();

                      @Override public Integer get(int index) {
                          return clone.nextSetBit(index);
                      }

                      @Override public int size() {
                          return clone.cardinality();
                      }
                  };

      Suppose indices 2 and 3 were selected before the call.
      The removed list as implemented above will look like [2, 2] instead of [2, 3] which should be obvious from the code.

      Why not use createListFromBitSet(...) as in clearAndSelect() ?

            jgiles Jonathan Giles
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: