[OpenJDK 2D-Dev] 8187898: PrintStream should override FilterOutputStream#write(byte[]) with a method that has no throws clause

Brian Burkhalter brian.burkhalter at oracle.com
Tue Jul 23 15:08:23 UTC 2019

> On Jul 23, 2019, at 12:45 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> On 23/07/2019 01:01, Brian Burkhalter wrote:
>> :
>> This version [1] adds writeBytes() and overrides write(byte[]) without changing its behavior. The documentation of write(byte[]) points the user to writeBytes() and write(byte[],int.int).
> The overridden write(byte[]) declares that it throws IOE so it's source compatible but it behaves like the other PS.write methods in that checkError is used to check for an error rather than throwing IOE.

I don’t see what you mean.
    public void write(byte buf[]) throws IOException {
Should “trouble” be set and the IOE re-thrown?

> This will need a bit more wording in the method description to make this clearer. The change to the class description is confusing as it suggests that the method throws IOE - maybe that change should be dropped to avoid trying to explain the oddity in two places.

The current statement in the class doc without any change is however incorrect

"Unlike other output streams, a PrintStream never throws an IOException; […]”

so it seems something is needed here.



More information about the core-libs-dev mailing list