RFR 4358774: Add null InputStream and OutputStream

Alan Bateman Alan.Bateman at oracle.com
Thu Dec 7 14:08:55 UTC 2017



On 06/12/2017 21:01, Jason Mehrens wrote:
> Brian,
>
> My understand is JDK-6533165 is moving the bytes that are rarely invoked to a cold method.
>
> Therefore:
> ====
> if (closed) {
>     throw new IOException("Stream closed");
> }
> ==becomes===
> if (closed) {
>     throw sc();
> }
>
> private static IOException sc() {
>      return new IOException("Stream closed");
> }
> ================================
>
If nothing else, a private ensureOpen method would make it easier to 
read so that the "if (closed) throw ..." isn't needed in every method.

-Alan


More information about the core-libs-dev mailing list