This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FYI: Patch: gnu.java.net.protocol.jar.Handler


Michael Koch wrote:

On Fri, Dec 19, 2003 at 06:45:42PM +0100, Guilhem Lavaux wrote:


Michael Koch wrote:



On Fri, Dec 19, 2003 at 06:28:00PM +0100, Guilhem Lavaux wrote:




Michael Koch wrote:





Hi list,


I commited the attached patch to merge gnu.java.net.protocol.jar.Handler with classpath again. This also fixes one mauve testcase and gives room for more fixes to jar URLs.








I've already written something concerning Jar handlers and it appeared that sun is throwing an Error in the sub-handler if the jar URL is mispelled: it is then possible to throw an InvalidURLException (or something like that) in URL parsers when the URL is mispelled. To be able not to confuse things, I had overridden Error and throwed this "special" error in parseUrl.

Unfortunately, the patch didn't come to classpath's CVS ...




Can you send me the patch for testing and probably commiting to libgcj
while classpath CVS is still down ?





Here is the patch against my latest classpath snapshot. But please excuse me, I haven't fixed the spaces...



What does SUNs JRE ? Does it throw an instance of Error too ? Or does it simply ignore it somehow ? If it ignore it we should just do the same in classpath and libgcj


Sorry, like an idiot I've forgotten to send you the last part of the patch. This translates URLParseError into MalformedURLException which the exception which is actually thrown by SUN's JRE.


I've extracted a small test from kaffe's regression test URLTest.java: you may see that the two exceptions are thrown at the same point in java.net.URL so it seems that sun's jre is translating an error into another.

Regards,
Guilhem.
--- /home/guilhem/ext2/PROJECTS/classpath/java/net/URL.java	2003-11-26 19:26:19.000000000 +0100
+++ java/net/URL.java	2003-12-20 10:00:40.000000000 +0100
@@ -432,8 +432,16 @@
     // is to be excluded by passing the 'limit' as the indexOf the '#'
     // if one exists, otherwise pass the end of the string.
     int hashAt = spec.indexOf('#', colon + 1);
-    this.ph.parseURL(this, spec, colon + 1,
-		     hashAt < 0 ? spec.length() : hashAt);
+    try
+      {
+        this.ph.parseURL(this, spec, colon + 1,
+                         hashAt < 0 ? spec.length() : hashAt);
+      }
+    catch (URLParseError e)
+      {
+        throw new MalformedURLException(e.getMessage());
+      }
+
     if (hashAt >= 0)
       ref = spec.substring(hashAt + 1);
 
import java.net.URL;

public class URLTest {
  static public void main(String args[]) throws Exception
  {
    try
      {
	URL u = new URL(null, "jar:http://www.kaffe.org/foo/bar.jar";);
      }
    catch (Exception e)
      {
	System.out.println(e.getMessage());
	e.printStackTrace();
      }

    try
      {
	URL u = new URL(null, "jar:abc!/test.java");
      }
    catch (Exception e)
      {
	System.out.println(e.getMessage());
	e.printStackTrace();
      }
  }
}

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]