< prev index next >

test/jdk/java/lang/StackWalker/CallerSensitiveMethod/csm/jdk/test/CallerSensitiveTest.java

Print this page
rev 47439 : 8189291: Test policy should extend the default system policy
Reviewed-by:

*** 1,7 **** /* ! * Copyright (c) 2016, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 40,49 **** --- 40,50 ---- * This test invokes StackWalker::getCallerClass via static reference, * reflection, MethodHandle, lambda. Also verify that * 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"; public static void main(String... args) throws Throwable { boolean sm = false;
*** 52,62 **** PermissionCollection perms = new Permissions(); perms.add(new RuntimePermission("getStackWalkerWithClassReference")); Policy.setPolicy(new Policy() { @Override public boolean implies(ProtectionDomain domain, Permission p) { ! return perms.implies(p); } }); System.setSecurityManager(new SecurityManager()); } --- 53,64 ---- PermissionCollection perms = new Permissions(); perms.add(new RuntimePermission("getStackWalkerWithClassReference")); Policy.setPolicy(new Policy() { @Override public boolean implies(ProtectionDomain domain, Permission p) { ! return perms.implies(p) || ! DEFAULT_POLICY.implies(domain, p); } }); System.setSecurityManager(new SecurityManager()); }
< prev index next >