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

Use Class.isInstance instead of Class.isAssignableFrom where applicable

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 19
    • None
    • core-libs
    • None
    • b24

      Method `Class.isAssignableFrom` is often used in form of:

          if (clazz.isAssignableFrom(obj.getClass())) {

      Such condition could be simplified to more shorter and performarnt code

          if (clazz.isInstance(obj)) {
          
      Replacement is equivalent if it's known that `obj != null`.
      In JDK codebase there are many such places.

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

              Created:
              Updated:
              Resolved: