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

java.util.Comparator::thenComparing has unnecessary type restriction

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b129
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :


        A DESCRIPTION OF THE PROBLEM :
        The following method of java.util.Comparator requires that type U extend java.lang.Comparable.

          <U extends Comparable<? super U>> Comparator<T> thenComparing(
            Function<? super T, ? extends U> keyExtractor,
            Comparator<? super U> keyComparator);

        But this restriction is unnecessary because keyComparator is used to compare extracted key objects.



        REPRODUCIBILITY :
        This bug can be reproduced always.

          Activity

          Hide
          henryjen Henry Jen added a comment -
          Victor:

          That is intentionally, in that API, we are comparing two Comparable using natural order.

          Show
          henryjen Henry Jen added a comment - Victor: That is intentionally, in that API, we are comparing two Comparable using natural order.
          Hide
          maxelsso Mathias Axelsson (Inactive) added a comment -
          Release team: Approved for fixing.
          Show
          maxelsso Mathias Axelsson (Inactive) added a comment - Release team: Approved for fixing.
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/7534523b4174
          User: henryjen
          Date: 2014-02-06 18:34:32 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/7534523b4174 User: henryjen Date: 2014-02-06 18:34:32 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/7534523b4174
          User: lana
          Date: 2014-02-06 23:00:06 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/7534523b4174 User: lana Date: 2014-02-06 23:00:06 +0000
          Hide
          amjiang Amanda Jiang added a comment -
          Verified, test/java/util/Comparator/TypeTest.java.testJDK8033590() passed with jdk8/b129
          Show
          amjiang Amanda Jiang added a comment - Verified, test/java/util/Comparator/TypeTest.java.testJDK8033590() passed with jdk8/b129

            People

            • Assignee:
              henryjen Henry Jen
              Reporter:
              henryjen Henry Jen
            • Votes:
              0 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: