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

Cleanup unnecessary null comparison before instanceof check in java.desktop

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P5 P5
    • 18
    • 16, 17, 18
    • client-libs
    • None
    • b27

      Update code checks both non-null and instance of a class in java.desktopmodule classes.
      The checks and explicit casts could also be replaced with pattern matching for the instanceof operator.
      For example the following code:

              if (parent != null) {
                  if (parent instanceof ScreenMenu) {
                      final ScreenMenu sm = (ScreenMenu)parent;
                      sm.setChildVisible(fInvoker, b);
                  }
              }


      Can be simplified to:
          
              if (parent instanceof ScreenMenu sm) {
                  sm.setChildVisible(fInvoker, b);
              }

            aturbanov Andrey Turbanov
            aturbanov Andrey Turbanov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: