This is the mail archive of the java-patches@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: java.util.zip.ZipFile fix


This patch fixes a bug in the ZipFile class. Now the interpreter can
finally load data from compressed .jar and .zip files!

I'm going to check this in.

regards

  [ bryce ]


	Fix for PR libgcj/228:
	* java/util/zip/ZipFile.java (getInputStream): Create inflater with 
	nowrapper option.
	
	* java/util/zip/natInflater.cc (inflate): Throw zlib's error message
	with DataFormatException.

Index: natInflater.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/zip/natInflater.cc,v
retrieving revision 1.6
diff -u -r1.6 natInflater.cc
--- natInflater.cc	2000/03/07 19:55:28	1.6
+++ natInflater.cc	2000/05/20 23:17:42
@@ -117,7 +117,8 @@
       break;
 
     case Z_DATA_ERROR:
-      _Jv_Throw (new java::util::zip::DataFormatException);
+      _Jv_Throw (new java::util::zip::DataFormatException 
+                 (s->msg == NULL ? NULL : JvNewStringLatin1 (s->msg)));
       break;
 
     case Z_MEM_ERROR:
Index: ZipFile.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/zip/ZipFile.java,v
retrieving revision 1.8
diff -u -r1.8 ZipFile.java
--- ZipFile.java	2000/04/11 20:02:48	1.8
+++ ZipFile.java	2000/05/20 23:17:43
@@ -133,7 +133,9 @@
 
     InputStream is = new ByteArrayInputStream (buffer);
     if (ze.getMethod() == ZipEntry.DEFLATED)
-      is = new InflaterInputStream (is);
+      // Data in zipfile entries does not have a zlib header, so construct
+      // an Inflater with the `nowrapper' option.
+      is = new InflaterInputStream (is, new Inflater (true), 512);
     return is;
   }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]