这是我的政策文件
grant {
permission java.util.PropertyPermission "*", "read,write";
permission java.lang.RuntimePermission "createClassLoader";
permission java.lang.RuntimePermission "setSecurityManager";
permission java.lang.RuntimePermission "createSecurityManager";
};
这是测试用例:
System.setProperty("java.security.policy", SECURITY_POLICY_BASEDIR + "/create-classloader.policy");
System.setSecurityManager(new SecurityManager());
System.getSecurityManager().checkCreateClassLoader();
System.setProperty("java.security.policy", "default"); // change policy at runtime
System.setSecurityManager(new SecurityManager());
System.getSecurityManager().checkCreateClassLoader(); // expecting a "AccessControlException"
我期待AccessControlException
在片段 2 的最后一行出现。任何指针?