On Tue, 23 Apr 2024 11:16:01 GMT, Jason Mehrens <[email protected]> wrote:
>> Brian Burkhalter has updated the pull request incrementally with one
>> additional commit since the last revision:
>>
>> Correct ID in test @bug tag
>
> src/java.base/share/classes/java/io/ByteArrayOutputStream.java line 164:
>
>> 162: public void writeTo(OutputStream out) throws IOException {
>> 163: if (Thread.currentThread().isVirtual()) {
>> 164: out.write(toByteArray());
>
> Would it be better to avoid calling a public method `toByteArray` encase
> subclass is overriding it?
A good question. The buf/count fields are protected so the subclass has direct
access to the bytes. So while it could Arrays.copy the bytes, it doesn't help
with a buggy subclass that is changing bytes while synchronization.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18901#discussion_r1576523112