8142464: PlatformLoggerTest.java throws java.lang.RuntimeException: Logger test.logger.bar does not exist

Test doesn't keep strong references to loggers

Reviewed-by: kvn
This commit is contained in:
Nils Eliasson 2016-04-29 09:40:08 +02:00
parent 0869129f03
commit c7f8bb25dd

@ -31,7 +31,6 @@
* *
* @modules java.base/sun.util.logging * @modules java.base/sun.util.logging
* java.logging/sun.util.logging.internal * java.logging/sun.util.logging.internal
* @compile -XDignore.symbol.file PlatformLoggerTest.java
* @run main/othervm PlatformLoggerTest * @run main/othervm PlatformLoggerTest
*/ */
@ -42,25 +41,31 @@ import sun.util.logging.PlatformLogger;
import static sun.util.logging.PlatformLogger.Level.*; import static sun.util.logging.PlatformLogger.Level.*;
public class PlatformLoggerTest { public class PlatformLoggerTest {
static Logger logger;
static PlatformLogger bar;
static PlatformLogger goo;
static PlatformLogger foo;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
final String FOO_PLATFORM_LOGGER = "test.platformlogger.foo"; final String FOO_PLATFORM_LOGGER = "test.platformlogger.foo";
final String BAR_PLATFORM_LOGGER = "test.platformlogger.bar"; final String BAR_PLATFORM_LOGGER = "test.platformlogger.bar";
final String GOO_PLATFORM_LOGGER = "test.platformlogger.goo"; final String GOO_PLATFORM_LOGGER = "test.platformlogger.goo";
final String BAR_LOGGER = "test.logger.bar"; final String BAR_LOGGER = "test.logger.bar";
PlatformLogger goo = PlatformLogger.getLogger(GOO_PLATFORM_LOGGER); goo = PlatformLogger.getLogger(GOO_PLATFORM_LOGGER);
// test the PlatformLogger methods // test the PlatformLogger methods
testLogMethods(goo); testLogMethods(goo);
// Create a platform logger using the default // Create a platform logger using the default
PlatformLogger foo = PlatformLogger.getLogger(FOO_PLATFORM_LOGGER); foo = PlatformLogger.getLogger(FOO_PLATFORM_LOGGER);
checkPlatformLogger(foo, FOO_PLATFORM_LOGGER); checkPlatformLogger(foo, FOO_PLATFORM_LOGGER);
// create a java.util.logging.Logger // create a java.util.logging.Logger
// now java.util.logging.Logger should be created for each platform logger // now java.util.logging.Logger should be created for each platform logger
Logger logger = Logger.getLogger(BAR_LOGGER); logger = Logger.getLogger(BAR_LOGGER);
logger.setLevel(Level.WARNING); logger.setLevel(Level.WARNING);
PlatformLogger bar = PlatformLogger.getLogger(BAR_PLATFORM_LOGGER); bar = PlatformLogger.getLogger(BAR_PLATFORM_LOGGER);
checkPlatformLogger(bar, BAR_PLATFORM_LOGGER); checkPlatformLogger(bar, BAR_PLATFORM_LOGGER);
// test the PlatformLogger methods // test the PlatformLogger methods