test/jdk/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
54 import java.util.concurrent.atomic.AtomicReference; |
54 import java.util.concurrent.atomic.AtomicReference; |
55 import jdk.internal.logger.SimpleConsoleLogger; |
55 import jdk.internal.logger.SimpleConsoleLogger; |
56 |
56 |
57 /** |
57 /** |
58 * @test |
58 * @test |
59 * @bug 8140364 |
59 * @bug 8140364 8189291 |
60 * @summary JDK implementation specific unit test for LoggerFinderLoader. |
60 * @summary JDK implementation specific unit test for LoggerFinderLoader. |
61 * Tests the behavior of LoggerFinderLoader with respect to the |
61 * Tests the behavior of LoggerFinderLoader with respect to the |
62 * value of the internal diagnosability switches. Also test the |
62 * value of the internal diagnosability switches. Also test the |
63 * DefaultLoggerFinder and SimpleConsoleLogger implementation. |
63 * DefaultLoggerFinder and SimpleConsoleLogger implementation. |
64 * @modules java.base/sun.util.logging |
64 * @modules java.base/sun.util.logging |
94 * @run main/othervm -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=QUIET LoggerFinderLoaderTest WITHPERMISSIONS |
94 * @run main/othervm -Xbootclasspath/a:boot -Djava.system.class.loader=CustomSystemClassLoader -Djdk.logger.finder.singleton=true -Djdk.logger.finder.error=QUIET LoggerFinderLoaderTest WITHPERMISSIONS |
95 * @author danielfuchs |
95 * @author danielfuchs |
96 */ |
96 */ |
97 public class LoggerFinderLoaderTest { |
97 public class LoggerFinderLoaderTest { |
98 |
98 |
|
99 static final Policy DEFAULT_POLICY = Policy.getPolicy(); |
99 static final RuntimePermission LOGGERFINDER_PERMISSION = |
100 static final RuntimePermission LOGGERFINDER_PERMISSION = |
100 new RuntimePermission("loggerFinder"); |
101 new RuntimePermission("loggerFinder"); |
101 final static boolean VERBOSE = false; |
102 final static boolean VERBOSE = false; |
102 static final ThreadLocal<AtomicBoolean> allowControl = new ThreadLocal<AtomicBoolean>() { |
103 static final ThreadLocal<AtomicBoolean> allowControl = new ThreadLocal<AtomicBoolean>() { |
103 @Override |
104 @Override |
864 return permissions; |
865 return permissions; |
865 } |
866 } |
866 |
867 |
867 @Override |
868 @Override |
868 public boolean implies(ProtectionDomain domain, Permission permission) { |
869 public boolean implies(ProtectionDomain domain, Permission permission) { |
869 return getPermissions().implies(permission); |
870 return getPermissions().implies(permission) || |
|
871 DEFAULT_POLICY.implies(domain, permission); |
870 } |
872 } |
871 |
873 |
872 @Override |
874 @Override |
873 public PermissionCollection getPermissions(CodeSource codesource) { |
875 public PermissionCollection getPermissions(CodeSource codesource) { |
874 return new PermissionsBuilder().addAll(getPermissions()).toPermissions(); |
876 return new PermissionsBuilder().addAll(getPermissions()).toPermissions(); |