--- old/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java 2015-10-09 21:41:53.000000000 +0200 +++ new/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java 2015-10-09 21:41:52.000000000 +0200 @@ -439,7 +439,8 @@ readConfiguration(); // Platform loggers begin to delegate to java.util.logging.Logger - sun.util.logging.PlatformLogger.redirectPlatformLoggers(); + sun.util.logger.BootstrapLogger.redirectTemporaryLoggers(); + } catch (Exception ex) { assert false : "Exception raised while reading logging configuration: " + ex; } @@ -1667,7 +1668,10 @@ } } - static final Permission controlPermission = new LoggingPermission("control", null); + static final Permission controlPermission = + new LoggingPermission("control", null); + static final Permission demandLoggerPermission = + new LoggingPermission("demandLogger", null); void checkPermission() { SecurityManager sm = System.getSecurityManager(); @@ -1911,4 +1915,32 @@ if (t instanceof RuntimeException) throw (RuntimeException)t; } + /** + * Demands a logger suitable for given caller. + *

+ * If a named logger suitable for the given caller is found + * returns it. + * Otherwise, creates a new logger suitable for the given caller. + * + * @param name The logger name. + * @param caller The caller on which behalf the logger is created/retrieved. + * @return A logger for the given caller. + * + * @throws SecurityException if the calling code doesn't have the + * {@link LoggingPermission LoggingPermission("demandLogger", null)}. + * @since 9 + */ + public static Logger demandLoggerFor(String name, /* Module */ Class caller) { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(demandLoggerPermission); + } + if (caller.getClassLoader() == null) { + return LogManager.getLogManager().demandSystemLogger(name, + Logger.SYSTEM_LOGGER_RB_NAME, caller); + } else { + return LogManager.getLogManager().demandLogger(name, null, caller); + } + } + }