The following patch fixes Classpath bug #13353:
https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=13353

Mauve test:
http://sources.redhat.com/ml/mauve-patches/2005/msg00053.html

Usage of fragments (#ref) in jar: URLs doesn't really seem to be
documented, but this patch makes Classpath behave more like Sun's JRE
and (more importantly) allows Apache Batik to parse SVG images.

-- 
Ziga

2005-06-09  Ziga Mahkovec  <[EMAIL PROTECTED]>

        Classpath bug #13353:
        * gnu/java/net/protocol/jar/Handler.java (parseURL, toExternalForm):
        Append fragments (#ref) to URLs.

Index: gnu/java/net/protocol/jar/Handler.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/net/protocol/jar/Handler.java,v
retrieving revision 1.10
diff -u -r1.10 Handler.java
--- gnu/java/net/protocol/jar/Handler.java	2 Mar 2005 17:29:09 -0000	1.10
+++ gnu/java/net/protocol/jar/Handler.java	9 Jun 2005 21:10:37 -0000
@@ -1,5 +1,5 @@
 /* gnu.java.net.protocol.jar.Handler - jar protocol handler for java.net
-   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -99,7 +99,7 @@
 	    
 	    file = file.substring (0, idx + 1) + url_string;
           }
-        else
+        else if (url_string.length() > 0)
           {
             int idx = file.lastIndexOf ("/");
             if (idx == -1) //context path is weird
@@ -156,14 +156,18 @@
   protected String toExternalForm (URL url)
   {
     String file = url.getFile();
+    String ref = url.getRef();
 
     // return "jar:" + file;
     // Performance!!: 
     //  Do the concatenation manually to avoid resize StringBuffer's 
-    //  internal buffer.
+    //  internal buffer.  The length of ref is not taken into consideration
+    //  as it's a rare path.
     StringBuffer sb = new StringBuffer (file.length() + 5);
     sb.append ("jar:");
     sb.append (file);
+    if (ref != null)
+      sb.append('#').append(ref);
     return sb.toString();
   }
 }
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to