java.net.URLClassLoader - new test for getResource loading directories

Robin Green greenrd@greenrd.org
Fri Dec 10 13:00:00 GMT 2004


Hi list,

Please apply the attached patch which adds checking that getResource()
works on directories as well as regular files. As a consequence, the first test
in getResource.java is wrong, because it says that getResource(".") should
fail, but . is a directory, so it should work. So I corrected that also.

This is to be consistent with sun JDK 1.4.2, and to try and get IBM ICU4j
(which expects this behaviour) working on a free runtime.

Also, where/how would I add a similar test for the system class loader?
-- 
Robin

P.S. Pedantically, to avoid delegation to the system class loader messing
up the test, this test should be run in a chroot, to ensure that no
accidentally-same-named directories exist ;-)
-------------- next part --------------
--- gnu/testlet/java/net/URLClassLoader/getResource.java.orig	2004-12-09 21:44:50.803057168 +0000
+++ gnu/testlet/java/net/URLClassLoader/getResource.java	2004-12-09 22:11:53.354391872 +0000
@@ -70,6 +70,8 @@
     jos.putNextEntry(je);
     jos.write(new byte[256]);
 
+    je = new JarEntry("path/in/jar/");
+    jos.putNextEntry(je);
     je = new JarEntry("path/in/jar/file");
     jos.putNextEntry(je);
     jos.write(new byte[256]);
@@ -112,16 +114,18 @@
 
 	URL u = ucl.getResource(".");
 	harness.debug(u != null ? u.toString() : null);
-	harness.check(u == null, "no .");
+	harness.check(u != null, ".");
 
 	u = ucl.getResource("..");
 	harness.debug(u != null ? u.toString() : null);
 	harness.check(u == null, "no ..");
 
 	check("testfile", "mauve-testdir", true);
+	check("testdir", "mauve-testdir", true);
 	check("testdir/test", "mauve-testdir", true);
 	check("jresource", "m.jar", false);
 	check("path/in/jar/file", "m.jar", false);
+	check("path/in/jar", "m.jar", false);
       }
     catch(IOException ioe)
       {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/mauve-patches/attachments/20041210/33e646f0/attachment.sig>


More information about the Mauve-patches mailing list