Comparator in TreeTableView has wrong generic type

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 8
    • Affects Version/s: 8
    • Component/s: javafx
    • Environment:

      jdk8 b115

      The default comparator in TreeTableView is a Comparator<TreeItem<S>>, not a Comparator<S> as indicated by the signature of the getComparator method. This causes the code below to fail with a ClassCastException:

          TreeTableView<Item> table = new TreeTableView<>(getRoot());
          table.comparatorProperty().addListener((ObservableValue<? extends Comparator<Item>> observable, Comparator<Item> oldValue, Comparator<Item> newValue) ->
              newValue.compare(new Item(0), new Item(1))
          );

      Workaround: getting rid of generics and explicitly casting to Comparator<TreeItem<Item>>.

            Assignee:
            Jonathan Giles
            Reporter:
            Yann Le Tallec (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: