# This patch aligns policy evaluation to be the same as the proprietary JDK.
# http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2010-July/009658.html
# https://bugs.openjdk.java.net/show_bug.cgi?id=100142

diff -up ./openjdk/jdk/src/share/classes/sun/security/provider/PolicyFile.java.sav ./jdk/src/share/classes/sun/security/provider/PolicyFile.java
--- ./openjdk.orig/jdk/src/share/classes/sun/security/provider/PolicyFile.java.sav	2010-04-20 14:49:13.000000000 -0400
+++ ./openjdk/jdk/src/share/classes/sun/security/provider/PolicyFile.java	2010-04-20 14:50:26.000000000 -0400
@@ -1799,6 +1799,27 @@ public class PolicyFile extends java.sec
 
         CodeSource canonCs = cs;
         URL u = cs.getLocation();
+        
+        // If this is a jar protocol url, collapse it to a 
+        // file protocol to process it as per the javadocs
+        if (u != null && u.getProtocol().equals("jar")) {
+            try {
+                String fileURL = "";
+            
+                // remove the initial jar:
+                fileURL = u.getPath();
+            
+                // remove the part after the !
+                fileURL = fileURL.substring(0, fileURL.indexOf('!'));
+                
+                u = new URL(fileURL);
+
+            } catch (Exception e) {
+                // Fail silently. In this case, url stays what it was above
+            }
+            
+        }
+        
         if (u != null && u.getProtocol().equals("file")) {
             boolean isLocalFile = false;
             String host = u.getHost();
