Added handling for the META-INF/INDEX.LIST file. 2006-05-08 Lillian Angel <[EMAIL PROTECTED]>
PR 27444 * java/net/URLClassLoader.java (JarURLLoader): Added code to go through META-INF/INDEX.LIST file to load all jars listed.
Index: java/net/URLClassLoader.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/net/URLClassLoader.java,v retrieving revision 1.46 diff -u -r1.46 URLClassLoader.java --- java/net/URLClassLoader.java 25 Mar 2006 20:31:08 -0000 1.46 +++ java/net/URLClassLoader.java 8 May 2006 14:03:21 -0000 @@ -39,6 +39,7 @@ package java.net; +import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.EOFException; import java.io.File; @@ -46,6 +47,7 @@ import java.io.FilePermission; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.security.AccessControlContext; import java.security.AccessController; import java.security.CodeSource; @@ -62,6 +63,7 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.Manifest; /** @@ -315,27 +318,50 @@ jarfile = ((JarURLConnection) baseJarURL.openConnection()).getJarFile(); - + Manifest manifest; Attributes attributes; String classPathString; + this.classPath = new Vector(); + + // This goes through the cached jar files listed + // in the INDEX.LIST file. All the jars found are added + // to the classPath vector so they can be loaded. + String dir = "META-INF/INDEX.LIST"; + jarfile.getEntry(dir); + BufferedReader br = new BufferedReader(new InputStreamReader(new URL(baseJarURL, + dir).openStream())); + String line = br.readLine(); + while (line != null) + { + if (line.endsWith(".jar")) + { + try + { + this.classPath.add(new URL(baseURL, line)); + } + catch (java.net.MalformedURLException xx) + { + // Give up + } + } + line = br.readLine(); + } + if ((manifest = jarfile.getManifest()) != null && (attributes = manifest.getMainAttributes()) != null && ((classPathString = attributes.getValue(Attributes.Name.CLASS_PATH)) != null)) - { - this.classPath = new Vector(); - + { StringTokenizer st = new StringTokenizer(classPathString, " "); while (st.hasMoreElements ()) { String e = st.nextToken (); try { - URL url = new URL(baseURL, e); - this.classPath.add(url); + this.classPath.add(new URL(baseURL, e)); } catch (java.net.MalformedURLException xx) {