I reverted this patch. It caused regressions.
I am going to look into the bug I had and try to think of a better
solution.

2006-05-10  Lillian Angel  <[EMAIL PROTECTED]>

        * java/util/SimpleTimeZone.java: Reverted patch.
        (SimpleTimeZone): Throw exception if startMonth ==
        endMonth.
        (SimpleTimeZone): Likewise.
        (checkRule): Rewritten to properly check all values (more
        efficently).
        This code is now more stable, at least less buggy than before.
        Fixed API documentation.
        (setStartRule): Moved checkRule call to end.
        (setStartRule): Likewise.
        (setEndRule): Likewise.
        (setEndRule): Likewise.


On Mon, 2006-05-01 at 16:39 -0400, Lillian Angel wrote:
> After testing a timezone app, I noticed that SimpleTimeZone is a little
> buggy. I fixed it up a bit... I imagine there are more bugs in this
> code. It does work better now.
> 
> 2006-05-01  Lillian Angel  <[EMAIL PROTECTED]>
> 
>         * java/util/SimpleTimeZone.java
>         (SimpleTimeZone): Do not throw exception if startMonth == 
>       endMonth.
>         (SimpleTimeZone): Likewise.
>         (checkRule): Rewritten to properly check all values (more 
>       efficently).
>         This code is now more stable, at least less buggy than before. 
>       Fixed API documentation.
>         (setStartRule): Moved checkRule call to end.
>         (setStartRule): Likewise.
>         (setEndRule): Likewise.
>         (setEndRule): Likewise.
> 
Index: gnu/java/net/IndexListParser.java
===================================================================
RCS file: gnu/java/net/IndexListParser.java
diff -N gnu/java/net/IndexListParser.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/net/IndexListParser.java	8 May 2006 21:25:14 -0000
@@ -0,0 +1,159 @@
+/* IndexListParser.java -- 
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.net;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.jar.JarFile;
+
+/**
+ * The INDEX.LIST file contains sections each separated by a blank line. 
+ * Each section defines the content of a jar, with a
+ * header defining the jar file path name, followed by a list of paths.
+ * The jar file paths are relative to the codebase of the root jar.
+ * 
+    Specification
+    index file :            version-info blankline section*
+    version-info :          JarIndex-Version: version-number
+    version-number :        digit+{.digit+}*
+    section :               body blankline
+    body :                  header name*
+    header :                char+.jar newline
+    name :                  char+ newline
+    
+ * @author langel at redhat dot com
+ */
+public class IndexListParser
+{
+  String filePath = "META-INF/INDEX.LIST";
+  String versInfo = "JarIndex-Version: ";
+  double versionNumber;
+  ArrayList headers = new ArrayList();
+  
+  /**
+   * Parses the given jarfile's INDEX.LIST file if it exists.
+   * 
+   * @param jarfile - the given jar file
+   * @param baseJarURL - the codebase of the jar file
+   * @param baseURL - the base url for the headers
+   */
+  public IndexListParser(JarFile jarfile, URL baseJarURL, URL baseURL)
+  {
+    try
+    {
+    // Parse INDEX.LIST if it exists
+    if (jarfile.getEntry(filePath) != null)
+      {
+        BufferedReader br = new BufferedReader(new InputStreamReader(new URL(baseJarURL,
+                                                                             filePath).openStream()));
+        
+        // Must start with version info
+        String line = br.readLine();
+        if (!line.startsWith(versInfo))
+          return;
+        versionNumber = Double.parseDouble(line.substring(versInfo.length()).trim());
+        
+        // Blank line must be next
+        line = br.readLine();
+        if (!line.equals(""))
+          {
+            clearAll();
+            return;
+          }
+        
+        // May contain sections
+        line = br.readLine();
+        while (line != null)
+          {
+            headers.add(new URL(baseURL, line));
+            
+            // Skip all names in the section
+            while (! (line = br.readLine()).equals(""));
+            line = br.readLine();
+          }
+      }
+    // else INDEX.LIST does not exist
+    }
+    catch (Exception ex)
+    {
+      clearAll();
+    }
+  }
+  
+  /**
+   * Clears all the variables. This is called when parsing fails.
+   */
+  void clearAll()
+  {
+    versionNumber = 0;
+    headers.clear();
+  }
+  
+  /**
+   * Gets the version info for the file.
+   * 
+   * @return the version info.
+   */
+  public String getVersionInfo()
+  {
+    return versInfo + getVersionNumber();
+  }
+  
+  /**
+   * Gets the version number of the file.
+   * 
+   * @return the version number.
+   */
+  public double getVersionNumber()
+  {
+    return versionNumber;
+  }
+  
+  /**
+   * Gets the array list of all the headers found in the file.
+   * 
+   * @return an array list of all the headers.
+   */
+  public ArrayList getHeaders()
+  {
+    return headers;
+  }
+}
Index: java/net/URLClassLoader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/URLClassLoader.java,v
retrieving revision 1.48
diff -u -r1.48 URLClassLoader.java
--- java/net/URLClassLoader.java	8 May 2006 15:25:18 -0000	1.48
+++ java/net/URLClassLoader.java	8 May 2006 21:25:14 -0000
@@ -39,7 +39,8 @@
 
 package java.net;
 
-import java.io.BufferedReader;
+import gnu.java.net.IndexListParser;
+
 import java.io.ByteArrayOutputStream;
 import java.io.EOFException;
 import java.io.File;
@@ -47,7 +48,6 @@
 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;
@@ -55,6 +55,7 @@
 import java.security.PrivilegedAction;
 import java.security.SecureClassLoader;
 import java.security.cert.Certificate;
+import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -323,32 +324,10 @@
 	  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";
-          if (jarfile.getEntry(dir) != null)
-            {
-              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();
-                }
-            }
+          
+          ArrayList indexListHeaders = new IndexListParser(jarfile, baseJarURL, baseURL).getHeaders();
+          if (indexListHeaders.size() > 0)
+            this.classPath.addAll(indexListHeaders);
           else if ((manifest = jarfile.getManifest()) != null
 	      && (attributes = manifest.getMainAttributes()) != null
 	      && ((classPathString 

Reply via email to