8189291: Test policy should extend the default system policy
authornaoto
Tue, 24 Oct 2017 08:56:30 -0700
changeset 47441 258dc79d2265
parent 47440 963f70aa578d
child 47442 560ee83bfce5
8189291: Test policy should extend the default system policy Reviewed-by: mchung
test/jdk/java/lang/StackWalker/CallerSensitiveMethod/csm/jdk/test/CallerSensitiveTest.java
test/jdk/java/lang/StackWalker/GetCallerClassTest.java
test/jdk/java/lang/System/LoggerFinder/internal/BaseDefaultLoggerFinderTest/BaseDefaultLoggerFinderTest.java
test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java
test/jdk/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java
test/jdk/java/lang/reflect/Proxy/nonPublicProxy/NonPublicProxyClass.java
test/jdk/java/net/URLPermission/nstest/LookupTest.java
test/jdk/java/util/concurrent/atomic/AtomicUpdaters.java
test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigWithInputStreamTest.java
test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/UpdateConfigurationTest.java
test/jdk/java/util/logging/Logger/setResourceBundle/TestSetResourceBundle.java
--- a/test/jdk/java/lang/StackWalker/CallerSensitiveMethod/csm/jdk/test/CallerSensitiveTest.java	Tue Oct 24 15:36:56 2017 +0200
+++ b/test/jdk/java/lang/StackWalker/CallerSensitiveMethod/csm/jdk/test/CallerSensitiveTest.java	Tue Oct 24 08:56:30 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,7 @@
  * StackWalker::getCallerClass can't be called from @CallerSensitive method.
  */
 public class CallerSensitiveTest {
+    static final Policy DEFAULT_POLICY = Policy.getPolicy();
     private static final String NON_CSM_CALLER_METHOD = "getCallerClass";
     private static final String CSM_CALLER_METHOD = "caller";
 
@@ -54,7 +55,8 @@
             Policy.setPolicy(new Policy() {
                 @Override
                 public boolean implies(ProtectionDomain domain, Permission p) {
-                    return perms.implies(p);
+                    return perms.implies(p) ||
+                        DEFAULT_POLICY.implies(domain, p);
                 }
             });
             System.setSecurityManager(new SecurityManager());
--- a/test/jdk/java/lang/StackWalker/GetCallerClassTest.java	Tue Oct 24 15:36:56 2017 +0200
+++ b/test/jdk/java/lang/StackWalker/GetCallerClassTest.java	Tue Oct 24 08:56:30 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8140450 8152893
+ * @bug 8140450 8152893 8189291
  * @summary Basic test for StackWalker.getCallerClass()
  * @run main/othervm GetCallerClassTest
  * @run main/othervm GetCallerClassTest sm
@@ -45,6 +45,7 @@
 import java.util.List;
 
 public class GetCallerClassTest {
+    static final Policy DEFAULT_POLICY = Policy.getPolicy();
     private final StackWalker walker;
     private final boolean expectUOE;
 
@@ -59,7 +60,8 @@
             Policy.setPolicy(new Policy() {
                 @Override
                 public boolean implies(ProtectionDomain domain, Permission p) {
-                    return perms.implies(p);
+                    return perms.implies(p) ||
+                        DEFAULT_POLICY.implies(domain, p);
                 }
             });
             System.setSecurityManager(new SecurityManager());
--- a/test/jdk/java/lang/System/LoggerFinder/internal/BaseDefaultLoggerFinderTest/BaseDefaultLoggerFinderTest.java	Tue Oct 24 15:36:56 2017 +0200
+++ b/test/jdk/java/lang/System/LoggerFinder/internal/BaseDefaultLoggerFinderTest/BaseDefaultLoggerFinderTest.java	Tue Oct 24 08:56:30 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,7 @@
 
 /**
  * @test
- * @bug     8140364 8145686
+ * @bug     8140364 8145686 8189291
  * @summary JDK implementation specific unit test for the base DefaultLoggerFinder.
  *          Tests the behavior of DefaultLoggerFinder and SimpleConsoleLogger
  *          implementation.
@@ -75,6 +75,7 @@
  */
 public class BaseDefaultLoggerFinderTest {
 
+    static final Policy DEFAULT_POLICY = Policy.getPolicy();
     static final RuntimePermission LOGGERFINDER_PERMISSION =
                 new RuntimePermission("loggerFinder");
     final static boolean VERBOSE = false;
@@ -959,7 +960,8 @@
 
         @Override
         public boolean implies(ProtectionDomain domain, Permission permission) {
-            return getPermissions().implies(permission);
+            return getPermissions().implies(permission) ||
+                    DEFAULT_POLICY.implies(domain, permission);
         }
 
         @Override
--- a/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java	Tue Oct 24 15:36:56 2017 +0200
+++ b/test/jdk/java/lang/System/LoggerFinder/internal/BootstrapLogger/BootstrapLoggerTest.java	Tue Oct 24 08:56:30 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
 
 /*
  * @test
- * @bug     8140364
+ * @bug     8140364 8189291
  * @author  danielfuchs
  * @summary JDK implementation specific unit test for JDK internal artifacts.
             Tests the behavior of bootstrap loggers (and SimpleConsoleLoggers
@@ -60,6 +60,7 @@
  */
 public class BootstrapLoggerTest {
 
+    static final Policy DEFAULT_POLICY = Policy.getPolicy();
     static final Method isAlive;
     static final Field logManagerInitialized;
     static {
@@ -365,7 +366,8 @@
 
         @Override
         public boolean implies(ProtectionDomain domain, Permission permission) {
-            return getPermissions(domain).implies(permission);
+            return getPermissions(domain).implies(permission) ||
+                   DEFAULT_POLICY.implies(domain, permission);
         }
 
         @Override
--- a/test/jdk/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java	Tue Oct 24 15:36:56 2017 +0200
+++ b/test/jdk/java/lang/System/LoggerFinder/internal/LoggerFinderLoaderTest/LoggerFinderLoaderTest.java	Tue Oct 24 08:56:30 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,7 @@
 
 /**
  * @test
- * @bug     8140364
+ * @bug     8140364 8189291
  * @summary JDK implementation specific unit test for LoggerFinderLoader.
  *          Tests the behavior of LoggerFinderLoader with respect to the
  *          value of the internal diagnosability switches. Also test the
@@ -96,6 +96,7 @@
  */
 public class LoggerFinderLoaderTest {
 
+    static final Policy DEFAULT_POLICY = Policy.getPolicy();
     static final RuntimePermission LOGGERFINDER_PERMISSION =
                 new RuntimePermission("loggerFinder");
     final static boolean VERBOSE = false;
@@ -866,7 +867,8 @@
 
         @Override
         public boolean implies(ProtectionDomain domain, Permission permission) {
-            return getPermissions().implies(permission);
+            return getPermissions().implies(permission) ||
+                   DEFAULT_POLICY.implies(domain, permission);
         }
 
         @Override
--- a/test/jdk/java/lang/reflect/Proxy/nonPublicProxy/NonPublicProxyClass.java	Tue Oct 24 15:36:56 2017 +0200
+++ b/test/jdk/java/lang/reflect/Proxy/nonPublicProxy/NonPublicProxyClass.java	Tue Oct 24 08:56:30 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 
 /*
  * @test
- * @bug 8004260
+ * @bug 8004260 8189291
  * @summary Test proxy classes that implement non-public interface
  *
  * @build p.Foo
@@ -48,6 +48,8 @@
  * @run main/othervm NonPublicProxyClass
  */
 public class NonPublicProxyClass {
+    static final Policy DEFAULT_POLICY = Policy.getPolicy();
+
     public interface PublicInterface {
         void foo();
     }
@@ -200,7 +202,8 @@
         }
 
         public boolean implies(ProtectionDomain domain, Permission perm) {
-            return permissions.implies(perm);
+            return permissions.implies(perm) ||
+                    DEFAULT_POLICY.implies(domain, perm);
         }
 
         public String toString() {
--- a/test/jdk/java/net/URLPermission/nstest/LookupTest.java	Tue Oct 24 15:36:56 2017 +0200
+++ b/test/jdk/java/net/URLPermission/nstest/LookupTest.java	Tue Oct 24 08:56:30 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,6 +54,7 @@
 
 public class LookupTest {
 
+    static final Policy DEFAULT_POLICY = Policy.getPolicy();
     static int port;
     static volatile ServerSocket serverSocket;
 
@@ -210,7 +211,7 @@
         }
 
         public boolean implies(ProtectionDomain domain, Permission perm) {
-            return perms.implies(perm);
+            return perms.implies(perm) || DEFAULT_POLICY.implies(domain, perm);
         }
     }
 }
--- a/test/jdk/java/util/concurrent/atomic/AtomicUpdaters.java	Tue Oct 24 15:36:56 2017 +0200
+++ b/test/jdk/java/util/concurrent/atomic/AtomicUpdaters.java	Tue Oct 24 08:56:30 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7103570
+ * @bug 7103570 8189291
  * @author David Holmes
  * @run main/othervm AtomicUpdaters
  * @run main/othervm AtomicUpdaters UseSM
@@ -47,6 +47,8 @@
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
 
 public class  AtomicUpdaters {
+    static final Policy DEFAULT_POLICY = Policy.getPolicy();
+
     enum TYPE { INT, LONG, REF }
 
     static class Config {
@@ -216,7 +218,8 @@
 
         @Override
         public boolean implies(ProtectionDomain pd, Permission p) {
-            return Policy.UNSUPPORTED_EMPTY_COLLECTION.implies(p);
+            return Policy.UNSUPPORTED_EMPTY_COLLECTION.implies(p) ||
+                    DEFAULT_POLICY.implies(pd, p);
         }
     }
 }
--- a/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigWithInputStreamTest.java	Tue Oct 24 15:36:56 2017 +0200
+++ b/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/SimpleUpdateConfigWithInputStreamTest.java	Tue Oct 24 08:56:30 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,13 +50,14 @@
 
 /**
  * @test
- * @bug 8033661
+ * @bug 8033661 8189291
  * @summary tests LogManager.updateConfiguration(InputStream, Function) method
  * @run main/othervm SimpleUpdateConfigWithInputStreamTest UNSECURE
  * @run main/othervm SimpleUpdateConfigWithInputStreamTest SECURE
  * @author danielfuchs
  */
 public class SimpleUpdateConfigWithInputStreamTest {
+    static final Policy DEFAULT_POLICY = Policy.getPolicy();
 
     /**
      * We will test updateConfiguration in
@@ -655,7 +656,8 @@
 
         @Override
         public boolean implies(ProtectionDomain domain, Permission permission) {
-            return getPermissions(domain).implies(permission);
+            return getPermissions(domain).implies(permission) ||
+                   DEFAULT_POLICY.implies(domain, permission);
         }
 
         public PermissionCollection permissions() {
--- a/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/UpdateConfigurationTest.java	Tue Oct 24 15:36:56 2017 +0200
+++ b/test/jdk/java/util/logging/LogManager/Configuration/updateConfiguration/UpdateConfigurationTest.java	Tue Oct 24 08:56:30 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,7 +59,7 @@
 
 /**
  * @test
- * @bug 8033661
+ * @bug 8033661 8189291
  * @summary tests LogManager.updateConfiguration(bin)
  * @modules java.logging/java.util.logging:open
  * @run main/othervm UpdateConfigurationTest UNSECURE
@@ -68,6 +68,8 @@
  */
 public class UpdateConfigurationTest {
 
+    static final Policy DEFAULT_POLICY = Policy.getPolicy();
+
     /**
      * We will test the handling of abstract logger nodes with file handlers in
      * two configurations:
@@ -594,7 +596,8 @@
         @Override
         public boolean implies(ProtectionDomain domain, Permission permission) {
             if (allowAll.get().get()) return allPermissions.implies(permission);
-            return permissions.implies(permission);
+            return permissions.implies(permission) ||
+                   DEFAULT_POLICY.implies(domain, permission);
         }
 
         @Override
--- a/test/jdk/java/util/logging/Logger/setResourceBundle/TestSetResourceBundle.java	Tue Oct 24 15:36:56 2017 +0200
+++ b/test/jdk/java/util/logging/Logger/setResourceBundle/TestSetResourceBundle.java	Tue Oct 24 08:56:30 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 
 /**
  * @test
- * @bug 8013839
+ * @bug 8013839 8189291
  * @summary tests Logger.setResourceBundle;
  * @build TestSetResourceBundle resources.ListBundle resources.ListBundle_fr
  * @run main/othervm TestSetResourceBundle UNSECURE
@@ -49,6 +49,7 @@
  */
 public class TestSetResourceBundle {
 
+    static final Policy DEFAULT_POLICY = Policy.getPolicy();
     static final String LIST_BUNDLE_NAME = "resources.ListBundle";
     static final String PROPERTY_BUNDLE_NAME = "resources.PropertyBundle";
 
@@ -479,7 +480,8 @@
 
         @Override
         public boolean implies(ProtectionDomain domain, Permission permission) {
-            return permissions.implies(permission);
+            return permissions.implies(permission) ||
+                   DEFAULT_POLICY.implies(domain, permission);
         }
     }