Thread.setContextClassLoader should use same RuntimePermission obj each time called when SM enabled

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: 7
    • Component/s: core-libs
    • None
    • sparc
    • solaris_10

      Thread.setContextClassLoader creates an unnecessary RuntimePermission object each
      time it is called when a SecurityManager is enabled:

       SecurityManager sm = System.getSecurityManager();
           if (sm != null) {
                  sm.checkPermission(new RuntimePermission("setContextClassLoader"));
           }
       
      This is unnecessary, a singleton should be used instead like the objects
      in sun.security.util.SecurityConstants, ex:

      public static final RuntimePermission SET_CONTEXT_CLASSLOADER_PERMISSION =
          new RuntimePermission("setContextClassLoader");

            Assignee:
            Sean Mullan
            Reporter:
            Sean Mullan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: