System.setProperty("java.security.policy", policy1File);
policy.refresh();
checkPolicy1Permissions(policy);
thr.setContextClassLoader(null);
policy.setPolicy(null, new PolicyFileProvider(policy0File));
policy.setPolicy(ldr1,
new DynamicPolicyProvider(new PolicyFileProvider(policy1File)));
checkPolicy0Permissions(policy);
if (policy.grantSupported()) {
throw new TestException("1-st grant is supported.");
}
try {
policy.grant(null, null,
new Permission[]{ new RuntimePermission("foo") });
throw new TestException("1-st grant does not throw exception.");
} catch (UnsupportedOperationException e) {
}
thr.setContextClassLoader(ldr1);
checkPolicy1Permissions(policy);
if (!policy.grantSupported()) {
throw new TestException("2-nd grant is not supported.");
}
policy.grant(null, null,
new Permission[]{ new RuntimePermission("foo") });
thr.setContextClassLoader(ldr2);
checkPolicy1Permissions(policy);
if (!policy.grantSupported()) {
throw new TestException("3-rd grant is not supported.");
}
policy.grant(null, null,
new Permission[]{ new RuntimePermission("foo") });
policy.setPolicy(ldr2, new PolicyFileProvider(policy0File));
checkPolicy0Permissions(policy);
if (policy.grantSupported()) {
throw new TestException("4-th grant is supported.");
}
try {