Lazy instantiation of Jar and Zip files

Mark Wielaard mark@klomp.org
Mon Nov 25 14:29:00 GMT 2002


Hi,

The following patch makes the creation of Jar and Zip files "lazy".
Reading of zip entries or Manifest files is done only when needed. Also
the creation of the Calendar object and conversion from/to dos time is
only done when get/setTime is called on the ZipEntry. The actual
ZipEntries are now stored in a Hashtable to make getEntry(String) more
efficient (especially important when an an entry cannot be found in a
large zip file).

2002-11-23  Mark Wielaard  <mark@klomp.org>

        * java/util/jar/JarFile.java (manifest): Not final.
        (manifestRead): New field.
        (JarFile): Don't read Manifest in constructor.
        (getManifest): New method.
        (JarEnumeration.nextElement): Use new method.
        (getEntry): Likewise.
        * java/util/zip/ZipFile.java (name): Final.
        (raf): Likewsie.
        (entries): Change type to Hashtable.
        (closed): New field.
        (ZipFile): Don't read enties in constructor.
        (readEntries): Use Hashtable.
        (close): Set new close flag and set entries to null inside 
        synchronized block.
        (entries): Contruct enumeration using new getEntries() method and 
        entries Hashtable. 
        (getEntryIndex): Removed.
        (getEntries): New method.
        (getEntry): Use new getEntries() method and entries Hastable.
        (getInputStream): Likewise.
        (size): Return getEntries().size().
        (ZipEntryEnumeration): Wrap entries Hashtable elements.
        * java/util/zip/ZipEntry.java (cal): Don't initialize.
        (time): Removed
        (dostime): New field.
        (zipFileIndex): Removed.
        (ZipEntry(ZipEntry)): Copy dostime.
        (setDOSTime): Now final and doesn't convert dos time.
        (getDOSTime): Likewise.
        (setTime): Convert dos time.
        (getTime): Likewise.
        (getCalendar): New method.
        (setExtra): Use setTime().
        * java/util/zip/ZipInputStream.java (getNextEntry): Format error msg.

OK to commit?

Cheers,

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jarzip.patch
Type: text/x-patch
Size: 16050 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20021125/e19a5c56/attachment.bin>


More information about the Java-patches mailing list