jdk/src/share/classes/sun/security/provider/PolicyFile.java
changeset 9771 0e8006984450
parent 9035 1255eb81cc2f
child 10336 0bb1999251f8
--- a/jdk/src/share/classes/sun/security/provider/PolicyFile.java	Mon May 16 12:58:48 2011 -0700
+++ b/jdk/src/share/classes/sun/security/provider/PolicyFile.java	Tue May 24 14:15:14 2011 -0700
@@ -1790,15 +1790,30 @@
 
         CodeSource canonCs = cs;
         URL u = cs.getLocation();
-        if (u != null && u.getProtocol().equals("file")) {
-            boolean isLocalFile = false;
-            String host = u.getHost();
-            isLocalFile = (host == null || host.equals("") ||
-                host.equals("~") || host.equalsIgnoreCase("localhost"));
+        if (u != null) {
+            if (u.getProtocol().equals("jar")) {
+                // unwrap url embedded inside jar url
+                String spec = u.getFile();
+                int separator = spec.indexOf("!/");
+                if (separator != -1) {
+                    try {
+                        u = new URL(spec.substring(0, separator));
+                    } catch (MalformedURLException e) {
+                        // Fail silently. In this case, url stays what
+                        // it was above
+                    }
+                }
+            }
+            if (u.getProtocol().equals("file")) {
+                boolean isLocalFile = false;
+                String host = u.getHost();
+                isLocalFile = (host == null || host.equals("") ||
+                    host.equals("~") || host.equalsIgnoreCase("localhost"));
 
-            if (isLocalFile) {
-                path = u.getFile().replace('/', File.separatorChar);
-                path = ParseUtil.decode(path);
+                if (isLocalFile) {
+                    path = u.getFile().replace('/', File.separatorChar);
+                    path = ParseUtil.decode(path);
+                }
             }
         }