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

Clarify Arrays' equals and mismatch that take a reference type and comparator

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 22
    • core-libs
    • None

      It's not sufficiently explicit that the comparator is used as an external equality check and, thus, only needs to reliably separate equal elements from unequal ones.

      It's important for a developer to be certain that it's fine to implement such a comparator, for example, like this:

          public static <T> Comparator<T> newEqualityComparator() {
              return (o1, o2) -> Objects.equals(o1, o2) ? 0 : -1;
          }

      Not only does it go against ingrained practices, but it might also be flagged as suspicious by IDEs and static analysis tools. So, more help and reassurance from documentation is in order.

            Unassigned Unassigned
            prappo Pavel Rappo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: