Patch: FYI: ZipEntry and DeflaterOutputStream fix

Tom Tromey tromey@redhat.com
Wed Jan 5 20:40:00 GMT 2005


I'm checking this in on the trunk.  I submitted an earlier version of
this patch a while back but this one has been updated to account for
compatibility tests I added to Mauve.

This fixes a couple of bugs reported by Caolan during his OOo testing.
Caolan, with these commits I think all the fixes we've discussed have
gone in.  Let me know if I missed something.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* java/util/zip/ZipEntry.java (setCompressedSize): Allow any
	argument.
	(compressedSize): Now 'long'.  Default to -1.
	(getCompressedSize): Rewrote.
	* java/util/zip/DeflaterOutputStream.java (deflate): Don't
	deflate at all if we need input.

Index: java/util/zip/DeflaterOutputStream.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/zip/DeflaterOutputStream.java,v
retrieving revision 1.13
diff -u -r1.13 DeflaterOutputStream.java
--- java/util/zip/DeflaterOutputStream.java 20 Oct 2004 08:09:25 -0000 1.13
+++ java/util/zip/DeflaterOutputStream.java 5 Jan 2005 20:34:17 -0000
@@ -79,13 +79,12 @@
    */
   protected void deflate() throws IOException
   {
-    do
+    while (! def.needsInput())
       {
 	int len = def.deflate(buf, 0, buf.length);
 	if (len > 0)
 	  out.write(buf, 0, len);
        }
-    while (! def.needsInput());
   }
 
   /** 
Index: java/util/zip/ZipEntry.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/zip/ZipEntry.java,v
retrieving revision 1.22
diff -u -r1.22 ZipEntry.java
--- java/util/zip/ZipEntry.java 7 Nov 2004 13:05:53 -0000 1.22
+++ java/util/zip/ZipEntry.java 5 Jan 2005 20:34:17 -0000
@@ -1,5 +1,5 @@
 /* ZipEntry.java --
-   Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -60,7 +60,7 @@
 
   private String name;
   private int size;
-  private int compressedSize;
+  private long compressedSize = -1;
   private int crc;
   private int dostime;
   private short known = 0;
@@ -242,14 +242,10 @@
 
   /**
    * Sets the size of the compressed data.
-   * @exception IllegalArgumentException if size is not in 0..0xffffffffL
    */
   public void setCompressedSize(long csize)
   {
-    if ((csize & 0xffffffff00000000L) != 0)
-	throw new IllegalArgumentException();
-    this.compressedSize = (int) csize;
-    this.known |= KNOWN_CSIZE;
+    this.compressedSize = csize;
   }
 
   /**
@@ -258,7 +254,7 @@
    */
   public long getCompressedSize()
   {
-    return (known & KNOWN_CSIZE) != 0 ? compressedSize & 0xffffffffL : -1L;
+    return compressedSize;
   }
 
   /**



More information about the Java-patches mailing list