Patch: FYI: fix PR 25389

Tom Tromey tromey@redhat.com
Wed Dec 14 17:32:00 GMT 2005


I'm checking this in to Classpath and libgcj 4.1 and trunk.

This fixes PR 25389, which was discovered by OO.o.  We were throwing
an NPE when we saw a non-hierarchical URI in the File constructor.
Instead we should be throwing an IllegalArgumentException.

I've updated the Mauve test to reflect this.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	PR classpath/25389:
	* java/io/File.java (File): Throw IllegalArgumentException if URI is
	non-hierarchical.

Index: java/io/File.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/File.java,v
retrieving revision 1.59
diff -u -r1.59 File.java
--- java/io/File.java	6 Nov 2005 20:28:00 -0000	1.59
+++ java/io/File.java	14 Dec 2005 17:28:28 -0000
@@ -406,7 +406,11 @@
     if (!uri.getScheme().equals("file"))
 	throw new IllegalArgumentException("invalid uri protocol");
 
-    path = normalizePath(uri.getPath());
+    String name = uri.getPath();
+    if (name == null)
+      throw new IllegalArgumentException("URI \"" + uri
+                     + "\" is not hierarchical");
+    path = normalizePath(name);
   }
 
   /**



More information about the Java-patches mailing list