RFR: 8251942: PrintStream specification is not clear which flush method is automatically invoked
Brian Burkhalter
bpb at openjdk.java.net
Thu Mar 11 20:57:24 UTC 2021
On Thu, 11 Mar 2021 19:09:08 GMT, Daniel Fuchs <dfuchs 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?
I think you are correct. In the second commit I scaled back the change to the class level specification. I left out any mention of "unspecified circumstances."
-------------
PR: https://git.openjdk.java.net/jdk/pull/2926
More information about the core-libs-dev
mailing list