PatchSet 4528 
Date: 2004/03/16 23:30:08
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Small fix for JBoss crash and speed up for class loading

2004-03-16  Dalibor Topic <[EMAIL PROTECTED]>

        * libraries/javalib/java/util/zip/ZipFile.java
        (close) Don't set zip to null when closing, otherwise
        getEntry on a closed zip file will crash.
        (closed) New field.
        (checkIfClosed) New method.
        (entries, getEntry, size): Use checkIfClosed.

        * libraries/javalib/kaffe/lang/PrimordialClassLoader.java
        (bootjars): New field.
        (findResources) Use bootjars to cache bootstrap jars.

Members: 
        ChangeLog:1.2106->1.2107 
        libraries/javalib/java/util/zip/ZipFile.java:1.12->1.13 
        libraries/javalib/kaffe/lang/PrimordialClassLoader.java:1.3->1.4 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2106 kaffe/ChangeLog:1.2107
--- kaffe/ChangeLog:1.2106      Tue Mar 16 17:44:34 2004
+++ kaffe/ChangeLog     Tue Mar 16 23:30:08 2004
@@ -1,5 +1,18 @@
 2004-03-16  Dalibor Topic <[EMAIL PROTECTED]>
 
+       * libraries/javalib/java/util/zip/ZipFile.java
+       (close) Don't set zip to null when closing, otherwise
+       getEntry on a closed zip file will crash.
+       (closed) New field.
+       (checkIfClosed) New method.
+       (entries, getEntry, size): Use checkIfClosed.
+
+       * libraries/javalib/kaffe/lang/PrimordialClassLoader.java
+       (bootjars): New field.
+       (findResources) Use bootjars to cache bootstrap jars.
+
+2004-03-16  Dalibor Topic <[EMAIL PROTECTED]>
+
        Resynced with GNU Classpath.
 
        2004-03-12  Mark Wielaard  <[EMAIL PROTECTED]>
Index: kaffe/libraries/javalib/java/util/zip/ZipFile.java
diff -u kaffe/libraries/javalib/java/util/zip/ZipFile.java:1.12 
kaffe/libraries/javalib/java/util/zip/ZipFile.java:1.13
--- kaffe/libraries/javalib/java/util/zip/ZipFile.java:1.12     Mon Oct 27 02:12:59 
2003
+++ kaffe/libraries/javalib/java/util/zip/ZipFile.java  Tue Mar 16 23:30:09 2004
@@ -33,9 +33,12 @@
    */
   public static final int OPEN_DELETE = 0x4;
 
+  // Name of this zip file.
+  private final String name;
 
-private String name;
-private Ptr zip;
+  private Ptr zip;
+
+  private boolean closed;
 
 public ZipFile(String fname) throws IOException
 {
@@ -57,23 +60,32 @@
        this(f);
 }
 
+private void checkIfClosed()
+{
+  if (closed) {
+    throw new IllegalStateException("Zip file already closed: " + getName());
+  }
+}
+
 public void close() throws IOException
 {
-       if (zip != null) {
+       if (!closed) {
                closeZipFile0(zip);
-               zip = null;
+               closed = true;
        }
 }
 
 public Enumeration entries()
 {
-       Vector all = getZipEntries0(zip);
-       return (all.elements());
+  checkIfClosed();
+  Vector all = getZipEntries0(zip);
+  return (all.elements());
 }
 
 public ZipEntry getEntry(String zname)
 {
-       return (getZipEntry0(zip, zname));
+  checkIfClosed();
+  return (getZipEntry0(zip, zname));
 }
 
 public InputStream getInputStream(ZipEntry ze) throws IOException
@@ -101,7 +113,8 @@
 
 public int size()
 {
-       return getZipFileSize0(zip);
+  checkIfClosed();
+  return getZipFileSize0(zip);
 }
 
 protected void finalize() throws IOException
Index: kaffe/libraries/javalib/kaffe/lang/PrimordialClassLoader.java
diff -u kaffe/libraries/javalib/kaffe/lang/PrimordialClassLoader.java:1.3 
kaffe/libraries/javalib/kaffe/lang/PrimordialClassLoader.java:1.4
--- kaffe/libraries/javalib/kaffe/lang/PrimordialClassLoader.java:1.3   Tue May 27 
21:28:04 2003
+++ kaffe/libraries/javalib/kaffe/lang/PrimordialClassLoader.java       Tue Mar 16 
23:30:09 2004
@@ -17,6 +17,8 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.Vector;
 import java.util.zip.ZipEntry;
@@ -36,6 +38,8 @@
 private static final Package[] NO_PACKAGES = new Package[0];
 private static final ProtectionDomain DEFAULT_PROTECTION_DOMAIN = new 
ProtectionDomain(null, null);
 
+private static final Map bootjars = new Hashtable();
+
 private PrimordialClassLoader() {
        super(null);
 }
@@ -136,23 +140,19 @@
                        continue;
                }
                if (file.isFile()) {
-                       ZipFile zip = null;
+                       ZipFile zip = (ZipFile) bootjars.get(file.getName());
                        try {
-                               zip = new ZipFile(file);
-                               ZipEntry entry = zip.getEntry(name);
-                               if (entry != null && !entry.isDirectory()) {
-                                   URL ju = new URL("jar:file:"
-                                       + 
file.getCanonicalPath().replace(File.separatorChar, '/') + "!/" + entry.getName());
-                                   v.addElement(ju);
-                               }
+                         if (zip == null) {
+                           zip = new ZipFile(file);
+                           bootjars.put(file.getName(), zip);
+                         }
+                         ZipEntry entry = zip.getEntry(name);
+                         if (entry != null && !entry.isDirectory()) {
+                           URL ju = new URL("jar:file:"
+                                            + 
file.getCanonicalPath().replace(File.separatorChar, '/') + "!/" + entry.getName());
+                           v.addElement(ju);
+                         }
                        } catch (IOException e) {
-                       } finally {
-                               if (zip != null) {
-                                       try {
-                                               zip.close();
-                                       } catch (IOException e) {
-                                       }
-                               }
                        }
                }
        }

_______________________________________________
kaffe mailing list
[EMAIL PROTECTED]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to