8227574: [TESTBUG] JTReg tests fail with Graal due to access denied
authornjian
Mon, 15 Jul 2019 03:14:28 +0000
changeset 55684 000138a6a4b3
parent 55683 b528b724b16d
child 55685 56b96d234f26
8227574: [TESTBUG] JTReg tests fail with Graal due to access denied Reviewed-by: kvn Contributed-by: xiaohong.gong@arm.com
test/jdk/java/net/URLPermission/URLTest.java
test/jdk/java/sql/testng/util/TestPolicy.java
--- a/test/jdk/java/net/URLPermission/URLTest.java	Fri Jul 12 12:19:58 2019 +0200
+++ b/test/jdk/java/net/URLPermission/URLTest.java	Mon Jul 15 03:14:28 2019 +0000
@@ -276,7 +276,9 @@
     }
 
     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 boolean implies(ProtectionDomain domain, Permission perm) {
-            return perms.implies(perm);
+            return perms.implies(perm) || DEFAULT_POLICY.implies(domain, perm);
         }
     }
 }
--- a/test/jdk/java/sql/testng/util/TestPolicy.java	Fri Jul 12 12:19:58 2019 +0200
+++ b/test/jdk/java/sql/testng/util/TestPolicy.java	Mon Jul 15 03:14:28 2019 +0000
@@ -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 @@
  * JDBC concrete classes
  */
 public class TestPolicy extends Policy {
+    static final Policy DEFAULT_POLICY = Policy.getPolicy();
 
     final PermissionCollection permissions = new Permissions();
 
@@ -137,6 +138,6 @@
 
     @Override
     public boolean implies(ProtectionDomain domain, Permission perm) {
-        return permissions.implies(perm);
+        return permissions.implies(perm) || DEFAULT_POLICY.implies(domain, perm);
     }
 }