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

Avoid use of a mapping function in Permissions.getPermissionCollection

    XMLWordPrintable

    Details

      Description

      JDK-8056179 refactored Permissions to use CHM, which was a performance improvement. There's however an unfortunate corner-case: if there's an unresolved permission, we'll always drop into the allocating block below in Permissions.getPermissionCollection during an implies call:

              return permsMap.computeIfAbsent(c,
                  new java.util.function.Function<>() {
                      @Override
                      public PermissionCollection apply(Class<?> k) {
                          ...
                  }
              }

      This adds an allocation and some overhead to each call.

      This block also adds some very slight startup and footprint overheads, since we create an extra anonymous class, and we take this overhead unconditionally (whether a SM is installed or not).

      By refactoring so that we avoid computeIfAbsent on the fast path, we can fix both issues.

        Attachments

          Activity

            People

            Assignee:
            redestad Claes Redestad
            Reporter:
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: