[cp-patches] Patch: FYI: fix class loading regression

Tom Tromey tromey at redhat.com
Wed Jun 14 14:27:42 UTC 2006


I'm checking this in.

Lillian and others have run into problems with our URLClassLoader not
handling the Class-Path attribute correctly.  I caused this regression
when I implemented index.list handling.

I tracked the problem down to 2 bugs.  One is that we weren't clearing
the index map if we didn't see an index.  Fixing this exposed another
bug, namely that sometimes a Class-Path attribute in a jar will
include the jar itself (this occurs in the jfreechart demo, for
instance), yielding infinite recursion.

Tom

2006-06-14  Tom Tromey  <tromey at redhat.com>

	* gnu/java/net/loader/JarURLLoader.java (initialize): Skip our own
	jar.
	* gnu/java/net/IndexListParser.java (IndexListParser): Call clearAll
	when index entry does not exist.

Index: gnu/java/net/IndexListParser.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/net/IndexListParser.java,v
retrieving revision 1.3
diff -u -r1.3 IndexListParser.java
--- gnu/java/net/IndexListParser.java	19 May 2006 20:58:59 -0000	1.3
+++ gnu/java/net/IndexListParser.java	14 Jun 2006 14:27:29 -0000
@@ -125,7 +125,11 @@
 
         br.close();
       }
-    // else INDEX.LIST does not exist
+    else
+      {
+        // INDEX.LIST does not exist
+        clearAll();
+      }
     }
     catch (Exception ex)
     {
Index: gnu/java/net/loader/JarURLLoader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/net/loader/JarURLLoader.java,v
retrieving revision 1.4
diff -u -r1.4 JarURLLoader.java
--- gnu/java/net/loader/JarURLLoader.java	21 May 2006 11:35:08 -0000	1.4
+++ gnu/java/net/loader/JarURLLoader.java	14 Jun 2006 14:27:29 -0000
@@ -135,6 +135,11 @@
                 try
                   {
                     URL subURL = new URL(baseURL, e);
+                    // We've seen at least one jar file whose Class-Path
+                    // attribute includes the original jar.  If we process
+                    // that normally we end up with infinite recursion.
+                    if (subURL.equals(baseURL))
+                      continue;
                     JarURLLoader subLoader = new JarURLLoader(classloader,
                                                               cache, factory,
                                                               subURL, subURL);



More information about the Classpath-patches mailing list