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

Cleanup unnecessary null comparison before instanceof check in java.naming

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P5
    • Resolution: Fixed
    • Affects Version/s: 16, 17
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
      None

      Description

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

              return (obj != null &&
                      obj instanceof CompoundName &&
                      impl.equals(((CompoundName)obj).impl));


      Can be simplified to:
          
              return (obj instanceof CompoundName other) &&
                      impl.equals(other.impl);

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: