On Thu, 28 Dec 2023 15:06:47 GMT, Sergey Tsypanov <stsypa...@openjdk.org> wrote:

>> It looks like we can skip copying of `byte[]` in 
>> `BufferedInputStream.implTransferTo()` for `OutputStreams` residing in 
>> `java.io`.
>> 
>> See comment by @vlsi in 
>> https://github.com/openjdk/jdk/pull/10525/files#diff-e19c508d1bb6ee78697ecca66947c395adda0d9c49a85bf696e677ecbd977af1R612
>
> Sergey Tsypanov has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   8320971: Fix test

test/jdk/java/io/BufferedInputStream/TransferToTrusted.java line 81:

> 79:                 bis.read();//need this to fill the BIS.buf in
> 80:                 bis.transferTo(out);
> 81:                 var internalBuffer = 
> bis.getClass().getDeclaredField("buf");

IMHO you don't need to whitebox here, as the blackbox approach described by me 
earlier should be sufficient to assert the claim of this PR.

test/jdk/java/io/BufferedInputStream/TransferToTrusted.java line 83:

> 81:                 var internalBuffer = 
> bis.getClass().getDeclaredField("buf");
> 82:                 internalBuffer.setAccessible(true);
> 83:                 if (!Arrays.equals(buf, Arrays.copyOf((byte[]) 
> internalBuffer.get(bis), length))) {

This is not testing the absence of a copy.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16879#discussion_r1435597922
PR Review Comment: https://git.openjdk.org/jdk/pull/16879#discussion_r1435598381

Reply via email to