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");
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");
- duplicates
-
JDK-4147755 (thread) Thread.setContextClassLoader should create permission only once
-
- Closed
-
- relates to
-
JDK-6387002 Improve security check performance
-
- Closed
-