jdk/test/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java
changeset 37672 03684934dc09
parent 36237 963d1115678b
child 42338 a60f280f803c
equal deleted inserted replaced
37671:7917477e22a8 37672:03684934dc09
    41 import java.util.Set;
    41 import java.util.Set;
    42 import java.util.stream.Collectors;
    42 import java.util.stream.Collectors;
    43 import java.util.stream.Stream;
    43 import java.util.stream.Stream;
    44 import jdk.internal.logger.BootstrapLogger;
    44 import jdk.internal.logger.BootstrapLogger;
    45 import jdk.internal.logger.LazyLoggers;
    45 import jdk.internal.logger.LazyLoggers;
       
    46 import java.lang.reflect.Module;
    46 
    47 
    47 /*
    48 /*
    48  * @test
    49  * @test
    49  * @bug     8140364
    50  * @bug     8140364
    50  * @author  danielfuchs
    51  * @author  danielfuchs
   103         System.setErr(new PrintStream(err));
   104         System.setErr(new PrintStream(err));
   104 
   105 
   105         if (BootstrapLogger.isBooted()) {
   106         if (BootstrapLogger.isBooted()) {
   106             throw new RuntimeException("VM should not be booted!");
   107             throw new RuntimeException("VM should not be booted!");
   107         }
   108         }
   108         Logger logger = LazyLoggers.getLogger("foo.bar", Thread.class);
   109         Logger logger = LazyLoggers.getLogger("foo.bar", Thread.class.getModule());
   109 
   110 
   110         if (test != TestCase.NO_SECURITY) {
   111         if (test != TestCase.NO_SECURITY) {
   111             LogStream.err.println("Setting security manager");
   112             LogStream.err.println("Setting security manager");
   112             Policy.setPolicy(new SimplePolicy());
   113             Policy.setPolicy(new SimplePolicy());
   113             System.setSecurityManager(new SecurityManager());
   114             System.setSecurityManager(new SecurityManager());
   259         }
   260         }
   260         Logger bazbaz = null;
   261         Logger bazbaz = null;
   261         SimplePolicy.allowAll.set(Boolean.TRUE);
   262         SimplePolicy.allowAll.set(Boolean.TRUE);
   262         try {
   263         try {
   263             bazbaz = java.lang.System.LoggerFinder
   264             bazbaz = java.lang.System.LoggerFinder
   264                     .getLoggerFinder().getLogger("foo.bar.baz.baz", BootstrapLoggerTest.class);
   265                     .getLoggerFinder().getLogger("foo.bar.baz.baz", BootstrapLoggerTest.class.getModule());
   265         } finally {
   266         } finally {
   266             SimplePolicy.allowAll.set(Boolean.FALSE);
   267             SimplePolicy.allowAll.set(Boolean.FALSE);
   267         }
   268         }
   268         if (!((Boolean)logManagerInitialized.get(null)).booleanValue()) {
   269         if (!((Boolean)logManagerInitialized.get(null)).booleanValue()) {
   269             throw new RuntimeException("LogManager should be initialized now!");
   270             throw new RuntimeException("LogManager should be initialized now!");