JDK-6538997 : Thread.setContextClassLoader should use same RuntimePermission obj each time called when SM enabled
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2007-03-26
  • Updated: 2010-04-03
  • Resolved: 2007-04-09
Related Reports
Duplicate :  
Relates :  
Description
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");

Comments
EVALUATION It turns out that this issue was reported several years ago (see 4147755) and not fixed for good reason - see the evaluation of 4147755 for more information.
09-04-2007

EVALUATION Yes, this will help reduce memory utilization.
03-04-2007