This is the mail archive of the
java-discuss@sourceware.cygnus.com
mailing list for the Java project.
Re: output stream bug
- To: jmc@cmpharm.ucsf.edu
- Subject: Re: output stream bug
- From: Bryce McKinlay <bryce@albatross.co.nz>
- Date: Wed, 16 Jun 1999 13:48:11 +1200
- CC: java-discuss@sourceware.cygnus.com
- References: <199906160029.RAA341913@arthur.ucsf.edu>
Try this patch:
Index: libjava/java/io/FilterOutputStream.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/io/FilterOutputStream.java,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 FilterOutputStream.java
--- FilterOutputStream.java 1999/04/07 14:52:36 1.1.1.1
+++ FilterOutputStream.java 1999/06/16 01:41:22
@@ -46,7 +46,7 @@
public void write (byte[] b) throws IOException, NullPointerException
{
// Don't do checking here, per Java Lang Spec.
- out.write (b);
+ write (b, 0, b.length);
}
public void write (byte[] b, int off, int len)
The JDK 1.2 docs say:
"The write method of FilterOutputStream calls its write method of three
arguments with the arguments b, 0,
and b.length.
Note that this method does not call the one-argument write method of its
underlying stream with the single argument b."
It looks like the three-argument write() method in FilterOutputStream is also
implemented wrong:
"The write method of FilterOutputStream calls the write method of one argument
on each byte to output.
Note that this method does not call the write method of its underlying input
stream with the same arguments. Subclasses of FilterOutputStream should provide
a more efficient implementation of this method."
regards
[ bryce ]
Bryce McKinlay
Distributed Information Systems Research
University of Otago
Dunedin, New Zealand
jmc@cmpharm.ucsf.edu wrote:
> There seems to be a bug when mixing write(byte) and write(byte[])
> calls to output streams. In a JVM, the following code writes
> "XoooXooo" like it should; in gcj compiled output, it writes
> "ooooooXX". I'm using the 6/8/99 snapshots of egcs and libgcj,
> compiled with --enable-fast-character --enable-threads=posix, on
> a linux 2.2.10 box.