7050329: test/java/security/Policy/GetPermissions/JarURL.java fails on Windows
authormullan
Sat, 04 Jun 2011 06:45:17 -0700
changeset 9790 b38864b89ce3
parent 9777 3f97b6a96ac5
child 9791 957da9b41ba4
7050329: test/java/security/Policy/GetPermissions/JarURL.java fails on Windows Reviewed-by: alanb
jdk/test/java/security/Policy/GetPermissions/JarURL.java
jdk/test/java/security/Policy/GetPermissions/JarURL.policy
--- a/jdk/test/java/security/Policy/GetPermissions/JarURL.java	Thu Jun 02 12:02:14 2011 -0400
+++ b/jdk/test/java/security/Policy/GetPermissions/JarURL.java	Sat Jun 04 06:45:17 2011 -0700
@@ -23,11 +23,13 @@
 
 /*
  * @test
- * @bug 7044443
+ * @bug 7044443 7050329
+ * @run main/othervm/policy=JarURL.policy JarURL
  * @summary Permissions resolved incorrectly for jar protocol
  */
 
 import java.net.URL;
+import java.io.File;
 import java.security.AllPermission;
 import java.security.CodeSource;
 import java.security.PermissionCollection;
@@ -35,11 +37,11 @@
 import java.security.cert.Certificate;
 
 public class JarURL {
+
     public static void main(String[] args) throws Exception {
-        URL codeSourceURL
-            = new URL("jar:file:"
-                      + System.getProperty("java.ext.dirs").split(":")[0]
-                      + "/foo.jar!/");
+        String userDir = System.getProperty("user.dir");
+        String jarURL = "jar:file:" + userDir + File.separator + "foo.jar!/";
+        URL codeSourceURL = new URL(jarURL);
         CodeSource cs = new CodeSource(codeSourceURL, new Certificate[0]);
         PermissionCollection perms = Policy.getPolicy().getPermissions(cs);
         if (!perms.implies(new AllPermission()))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/Policy/GetPermissions/JarURL.policy	Sat Jun 04 06:45:17 2011 -0700
@@ -0,0 +1,8 @@
+grant codeBase "file:${user.dir}/*" {
+    permission java.security.AllPermission;
+};
+
+grant {
+    permission java.util.PropertyPermission "user.dir", "read";
+    permission java.security.SecurityPermission "getPolicy";
+};