This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: OpenOffice.org: AbstractMethod error with Sun's jaxp/parser
Caolan> JarEntry.setCompressedSize(-1) works with sunjava and not with
Caolan> gcj
This is easy to fix -- just removing a check. I wonder what the valid
values really are.
Caolan> and JarOutputStream.write(byte[]) where byte[] is of length 0 passes
Caolan> silently with sunjava and not with gcj.
I think the only question here is whether to fix it in
DeflaterOutputStream.write() or in the deflater. Hmm, maybe
DeflaterOutputStream.deflate should use while instead of do/while.
I think we have a potential gc-related bug in Deflater, we don't keep
a gc-visible reference to the argument to setInput. Oops. (This is
unlikely to be triggered though.)
Here's a minimalist patch you could try. It worked for me on your
test case. I made a note on my to-do list to clean up this patch
(meaning test setCompressedSize a bit).
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* java/util/zip/ZipEntry.java (setCompressedSize): Allow -1 as
argument.
* 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 30 Nov 2004 23:18:50 -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 30 Nov 2004 23:18:51 -0000
@@ -246,10 +246,13 @@
*/
public void setCompressedSize(long csize)
{
- if ((csize & 0xffffffff00000000L) != 0)
+ if ((csize & 0xffffffff00000000L) != 0 && csize != -1)
throw new IllegalArgumentException();
this.compressedSize = (int) csize;
- this.known |= KNOWN_CSIZE;
+ if (csize == -1)
+ this.known &= ~KNOWN_CSIZE;
+ else
+ this.known |= KNOWN_CSIZE;
}
/**