changeset 4289:49aef5a5416e

7050329: test/java/security/Policy/GetPermissions/JarURL.java fails on Windows Reviewed-by: alanb
author mullan
date Sat, 04 Jun 2011 06:45:17 -0700
parents a00f48c96345
children 1f39ca0b9598
files test/java/security/Policy/GetPermissions/JarURL.java test/java/security/Policy/GetPermissions/JarURL.policy
diffstat 2 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/security/Policy/GetPermissions/JarURL.java	Thu Jun 02 12:02:14 2011 -0400
+++ b/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/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";
+};