On Mon, 4 Dec 2023 13:16:25 GMT, Alan Bateman <al...@openjdk.org> wrote:
>it doesn't solve the second part of the concern which is read-only view on the >internal buffer. I think `ByteBuffer.asReadOnlyBuffer()` should resolve the issues regarding naked byte access. At least `ByteBuffer#array()` returns `null` for read-only buffers, and `ByteBuffer#hasArray()` returns `false`. Am I missing something? I've created https://bugs.openjdk.org/browse/JDK-8321271 to track `OutputStream.write(ByteBuffer)` as I think it would avoid mixing discussions on `transferTo` and `OutputStream.write(ByteBuffer)` which would be useful even beyond the scope of transferTo. --- > WBC specifies that writes executing serially and also specifies the exception > when attempting to write to a closed channel, both of which are not > compatible with OutputStream There's `Channel#isOpen` as well which is hard to tell for a generic `InputStream`. On the other hand, what if `OutputStream` declares its own `write(ByteBuffer)` method? (that is JDK-8321271) ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/16879#discussion_r1413874663