On Wed, 24 Apr 2024 07:08:20 GMT, Alan Bateman <al...@openjdk.org> wrote:

>> So do we think it better not to invoke `toByteArray` here?
>
> Using a subclass to count the number of invocations of toByteArray seems a 
> bit strange but in general it is more robust to not rely on a method that may 
> be overridden by a subclass. So I think the suggestion is good.

Currently we have

    public void writeTo(OutputStream out) throws IOException {
        if (Thread.currentThread().isVirtual()) {
            out.write(toByteArray());
        } else synchronized (this) {
            out.write(buf, 0, count);
        }
    }

where `toByteArray()` is `synchronized`, but here I would think that we'd want 
to replace it with simply `Arrays.copyOf(buf, count)` without the 
`synchronized`, no?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18901#discussion_r1578031656

Reply via email to