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: BufferedOutputStream patch


OK, here's what the JDK behavior is... it does in fact differ
between BufferedWriter and BufferedOutputStream, but not between
JDK 1.1 and 1.2 (tested on 1.1.6 on Irix, and 1.2pre1 on Linux):

OS, byte - flush on overflow
OS, byte[] - overflow
Wr, char - overflow
Wr, char[] - fill(!)

And here's the current libjava behavior:

OS, byte - overflow
OS, byte[] - fill
Wr, char - fill
Wr, char[] - fill

The docs you quoted in the previous msg imply there is a difference
between Writer and OutputStream behavior, although not between single
character and array operations.

My patch "fixes" the first difference (in BOS) to bring it in line
with the JDK; the difference in BWr should be patched also, IMO.

My opinion is that in cases where the JDK docs are unclear on
inconsistent, libjava should duplicate observed JDK behavior... I
assume comparing testcase ouput is kosher as long as one doesn't
actually look at the JDK source.  In cases where the JDK behavior
is contrary to the documentation, that's a different problem!
Sun is pretty good about fixing one or the other...

For anyone who wants to duplicate my testcase for Writers, here's
a code fragment; note that one has to be careful since OutputStreamWriter
also buffers its output.  This buffer size cannot be specified, so
one has to flush to make sure nothing is there:

  OutputStreamWriter osw = new OutputStreamWriter(System.out);
  Writer outfile = new BufferedWriter(osw,6);
  for (int i=0; i<6; i++)
      outfile.write('X');
  // or:  2 writes of a char[] containing XXX
  osw.flush();

JMC
-- 
John-Marc Chandonia (jmc@cmpharm.ucsf.edu)              We're everywhere...
Cohen Lab, University of California San Francisco       for your convenience.
http://yuri.harvard.edu/~jmc                                -- Psi Corps <*>

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