diff --git a/jdk/test/java/util/concurrent/atomic/AtomicUpdaters.java b/jdk/test/java/util/concurrent/atomic/AtomicUpdaters.java index 62d066914d2..8728224ce8e 100644 --- a/jdk/test/java/util/concurrent/atomic/AtomicUpdaters.java +++ b/jdk/test/java/util/concurrent/atomic/AtomicUpdaters.java @@ -33,7 +33,7 @@ */ import java.util.concurrent.atomic.*; import java.lang.reflect.*; -import java.security.AccessControlException; +import java.security.*; public class AtomicUpdaters { enum TYPE { INT, LONG, REF } @@ -102,6 +102,8 @@ public class AtomicUpdaters { verbose = true; } else if ("UseSM".equals(arg)) { + // Ensure that the test is not influenced by the default users policy. + Policy.setPolicy(new NoPermissionsPolicy()); SecurityManager m = System.getSecurityManager(); if (m != null) throw new RuntimeException("No security manager should initially be installed"); @@ -186,4 +188,24 @@ public class AtomicUpdaters { throw new Error("Some tests failed - see previous stacktraces"); } } + + /** + * Policy with no permissions. + */ + private static class NoPermissionsPolicy extends Policy { + @Override + public PermissionCollection getPermissions(CodeSource cs) { + return Policy.UNSUPPORTED_EMPTY_COLLECTION; + } + + @Override + public PermissionCollection getPermissions(ProtectionDomain pd) { + return Policy.UNSUPPORTED_EMPTY_COLLECTION; + } + + @Override + public boolean implies(ProtectionDomain pd, Permission p) { + return Policy.UNSUPPORTED_EMPTY_COLLECTION.implies(p); + } + } }