This is the mail archive of the java-discuss@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]

Re: output stream bug


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.


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