8227574: [TESTBUG] JTReg tests fail with Graal due to access denied

Reviewed-by: kvn
This commit is contained in:
Xiaohong Gong 2019-07-15 03:14:28 +00:00 committed by Ningsheng Jian
parent 74143d5ab8
commit 53635b436c
2 changed files with 6 additions and 3 deletions

View File

@ -276,7 +276,9 @@ public class URLTest {
}
static class CustomPolicy extends Policy {
static final Policy DEFAULT_POLICY = Policy.getPolicy();
final PermissionCollection perms = new Permissions();
CustomPolicy(Permission... permissions) {
java.util.Arrays.stream(permissions).forEach(perms::add);
@ -301,7 +303,7 @@ public class URLTest {
}
public boolean implies(ProtectionDomain domain, Permission perm) {
return perms.implies(perm);
return perms.implies(perm) || DEFAULT_POLICY.implies(domain, perm);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2019, 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 @@ import java.util.logging.LoggingPermission;
* JDBC concrete classes
*/
public class TestPolicy extends Policy {
static final Policy DEFAULT_POLICY = Policy.getPolicy();
final PermissionCollection permissions = new Permissions();
@ -137,6 +138,6 @@ public class TestPolicy extends Policy {
@Override
public boolean implies(ProtectionDomain domain, Permission perm) {
return permissions.implies(perm);
return permissions.implies(perm) || DEFAULT_POLICY.implies(domain, perm);
}
}