This is the mail archive of the
kawa@sourceware.cygnus.com
mailing list for the Kawa project.
Re: verification puzzle
- To: kawa at sourceware dot cygnus dot com
- Subject: Re: verification puzzle
- From: brlewis at alum dot mit dot edu
- Date: Mon, 6 Dec 1999 09:39:42 -0500
- References: <m266yi9ieo.fsf@magnus.bothner.com> <199912021457.JAA25632@tux.eato\
--text follows this line--
Per Bothner <per@bothner.com> writes:
> It would be nice to fix Kawa so it generated correct .zip archives.
> One approach would be to change ZipArchive so it uses java.util.zip.CRC32.
> But since the point of ZipArchive is questionable now that java.util.zip.CRC3\
2.
> is widely available, I think a better solution is to modify gnu.expr.ModifyEx\
pr
> so the compileToArchive method uses java.util.zip.ZipOutputStream instead
> of gnu.bytecode.ZipArchive. This should be an easy job; any volunteers?
The following works. Haven't tested yet to see if the jdk1.2 bug is
still triggered.
Index: ModuleExp.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/expr/ModuleExp.java,v
retrieving revision 1.3
diff -u -r1.3 ModuleExp.java
--- ModuleExp.java 1999/03/11 10:57:06 1.3
+++ ModuleExp.java 1999/12/06 14:34:27
@@ -1,5 +1,6 @@
package gnu.expr;
import java.io.*;
+import java.util.zip.*;
import gnu.mapping.*;
import gnu.bytecode.*;
@@ -65,18 +66,28 @@
File zar_file = new File (fname);
if (zar_file.exists ())
zar_file.delete ();
- ZipArchive zar = new ZipArchive (zar_file, "rw");
+ ZipOutputStream zout
+ = new ZipOutputStream (new FileOutputStream (zar_file));
+ zout.setMethod(zout.STORED); // no compression
byte[][] classes = new byte[comp.numClasses][];
+ CRC32 zcrc = new CRC32();
for (int iClass = 0; iClass < comp.numClasses; iClass++)
{
ClassType clas = comp.classes[iClass];
classes[iClass] = clas.writeToArray ();
+ ZipEntry zent = new ZipEntry(clas.getName ().replace ('.', '/')
+ + ".class");
- zar.append (clas.getName ().replace ('.', '/') + ".class",
- classes[iClass]);
+ zent.setSize(classes[iClass].length);
+ zcrc.reset();
+ zcrc.update(classes[iClass], 0, classes[iClass].length);
+ zent.setCrc(zcrc.getValue());
+
+ zout.putNextEntry (zent);
+ zout.write (classes[iClass]);
}
- zar.close ();
+ zout.close ();
}
}
--
Bruce R. Lewis <URL:http://web.mit.edu/brlewis/www/>