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

Optimize Class.isAnonymousClass, isLocalClass, and isMemberClass

    XMLWordPrintable

Details

    • b149
    • Not verified

    Description

      Class.isAnonymousClass is implemented as:

          public boolean isAnonymousClass() {
              return "".equals(getSimpleName());
          }

      However, getSimpleName generates quite a few superfluous objects that could be avoided if isAnonymousClass was implemented to check the conditions that will lead it to return "" more directly:

          public boolean isAnonymousClass() {
              return !isArray() && getEnclosingMethodInfo() != null &&
                      getSimpleBinaryName0() == null;
          }

      This reduces the average cost of isAnonymousClass by around 65%, which should be worthwhile since this is both a public API and a component of other internal methods in wide internal use.

      Attachments

        Activity

          People

            redestad Claes Redestad
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: