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

Simplify equals() call on nullable variable and a constant in java.desktop

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P5
    • Resolution: Fixed
    • Affects Version/s: 17
    • Fix Version/s: 18
    • Component/s: client-libs
    • Labels:
      None
    • Resolved In Build:
      b19

      Description

      Flipping arguments of 'equals' method, allows simplifying boolean expressions: now we can remove redundant null check before.
      Example:

                  String parent = dir.getParent();
                  if (parent != null && parent.equals("/net")) {
                      return true;
                  }

      Can be simplified to:
                  String parent = dir.getParent();
                  if ("/net".equals(parent)) {
                      return true;
                  }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              aturbanov Andrey Turbanov
              Reporter:
              aturbanov Andrey Turbanov
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: