8227615: [TESTBUG] JTReg "jdk/sun/security/util/FilePermCompat/CompatImpact.java" fails with graal
Reviewed-by: kvn
Contributed-by: xiaohong.gong@arm.com
--- a/test/jdk/sun/security/util/FilePermCompat/CompatImpact.java Tue Jul 16 00:57:00 2019 +0000
+++ b/test/jdk/sun/security/util/FilePermCompat/CompatImpact.java Wed Jul 17 10:11:05 2019 +0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -90,7 +90,7 @@
.debug(testcase)
.start();
if (p.waitFor() != 0) {
- Files.copy(Paths.get("stderr." + testcase), System.out);
+ Files.copy(Paths.get(testcase + ".stderr"), System.out);
failed += testcase + " ";
}
@@ -101,7 +101,7 @@
.debug(testcase)
.start();
if (p.waitFor() != 0) {
- Files.copy(Paths.get("stderr." + testcase), System.out);
+ Files.copy(Paths.get(testcase + ".stderr"), System.out);
failed += testcase + " ";
}
@@ -114,7 +114,7 @@
.debug(testcase)
.start();
if (p.waitFor() != 0) {
- Files.copy(Paths.get("stderr." + testcase), System.out);
+ Files.copy(Paths.get(testcase + ".stderr"), System.out);
failed += testcase + " ";
}
@@ -126,7 +126,7 @@
.debug(testcase)
.start();
if (p.waitFor() != 0) {
- Files.copy(Paths.get("stderr." + testcase), System.out);
+ Files.copy(Paths.get(testcase + ".stderr"), System.out);
failed += testcase + " ";
}
@@ -138,7 +138,7 @@
.debug(testcase)
.start();
if (p.waitFor() != 0) {
- Files.copy(Paths.get("stderr." + testcase), System.out);
+ Files.copy(Paths.get(testcase + ".stderr"), System.out);
failed += testcase + " ";
}
@@ -238,6 +238,7 @@
// For my policy, f is passed into test and new MP(f)
// will be set as new policy
p.perm(new SecurityPermission("setPolicy"));
+ p.perm(new SecurityPermission("getPolicy"));
p.args(f);
break;
default:
@@ -249,7 +250,9 @@
// My own Policy impl, with only one granted permission, also not smart
// enough to know whether ProtectionDomain grants any permission
static class MP extends Policy {
+ static final Policy DEFAULT_POLICY = Policy.getPolicy();
final PermissionCollection pc;
+
MP(String f) {
FilePermission p = new FilePermission(f, "read");
pc = p.newPermissionCollection();
@@ -267,7 +270,7 @@
@Override
public boolean implies(ProtectionDomain domain, Permission permission) {
- return pc.implies(permission);
+ return pc.implies(permission) || DEFAULT_POLICY.implies(domain, permission);
}
}
}