RFR: 8251942: PrintStream specification is not clear which flush method is automatically invoked

Daniel Fuchs dfuchs at openjdk.java.net
Thu Mar 11 19:12:07 UTC 2021


On Wed, 10 Mar 2021 23:03:03 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Please review this minor change to the specification of `java.io.PrintStream`. The longstanding behavior for flushing is to invoke the `flush()` method of the underlying `OutputStream` rather than its override but this was not made explicit in the specification.

> Yes, I noticed that as well. I didn?t think it was worth complicating things for the purpose of this issue to address it.

I guess what I was trying to ask is whether we should actually specify that `print` and `append` call `flush` - as this seems to be a side effect of some optimization.
Maybe we should say that the implementation ensures that flush is called when writing a byte array or when  a newline character or byte ({@code '\n'}) is written - but might call it in additional unspecified circumstances?

-------------

PR: https://git.openjdk.java.net/jdk/pull/2926


More information about the core-libs-dev mailing list