mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-09 15:42:10 +00:00
8024867: Enhance logging start up
Reviewed-by: mchung, hawtin
This commit is contained in:
parent
8b89580a17
commit
61e7dbb67e
@ -241,6 +241,11 @@ public class LogManager {
|
||||
* retrieved by calling LogManager.getLogManager.
|
||||
*/
|
||||
protected LogManager() {
|
||||
this(checkSubclassPermissions());
|
||||
}
|
||||
|
||||
private LogManager(Void checked) {
|
||||
|
||||
// Add a shutdown hook to close the global handlers.
|
||||
try {
|
||||
Runtime.getRuntime().addShutdownHook(new Cleaner());
|
||||
@ -250,6 +255,19 @@ public class LogManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static Void checkSubclassPermissions() {
|
||||
final SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
// These permission will be checked in the LogManager constructor,
|
||||
// in order to register the Cleaner() thread as a shutdown hook.
|
||||
// Check them here to avoid the penalty of constructing the object
|
||||
// etc...
|
||||
sm.checkPermission(new RuntimePermission("shutdownHooks"));
|
||||
sm.checkPermission(new RuntimePermission("setContextClassLoader"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy initialization: if this instance of manager is the global
|
||||
* manager then this method will read the initial configuration and
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user