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

Minor issue in JavacFileManager.SortFiles.REVERSE

    XMLWordPrintable

Details

    • b14

    Description

      SonarCloud reports the problem in JavacFileManager.SortFiles.REVERSE definition:
       Neither "Math.abs" nor negation should be used on numbers that could be "MIN_VALUE"

              REVERSE {
                  @Override
                  public int compare(Path f1, Path f2) {
                      return -f1.getFileName().compareTo(f2.getFileName());
                  }
              }

      Since compareTo can technically return MIN_VALUE, we cannot simply negate it. Luckily, we can just swap the f1 and f2 comparison order to achieve the same effect without exposing us to this corner case.

      Attachments

        Issue Links

          Activity

            People

              shade Aleksey Shipilev
              shade Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: