RFR: 8320971: Use BufferedInputStream.buf directly when param of implTransferTo() is trusted [v15]

Alan Bateman alanb at openjdk.org
Sun Dec 17 09:09:43 UTC 2023


On Thu, 14 Dec 2023 08:47:03 GMT, Sergey Tsypanov <stsypanov at 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: Revert irrelevant changes

For the method description, I think you can expand it to:

- does not retain a reference to the byte[]
- does not leak a reference to the byte[] to non-trusted classes
- does not modify the contents of the byte[]
- its 3-arg write does not read the contents outside of the offset/length bounds

In passing, this class uses "out" for the target OutputStream in the other methods, you can keep that consistent. Also I assume the `@see` are left over from a previous iteration.

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

PR Comment: https://git.openjdk.org/jdk/pull/16879#issuecomment-1859080164


More information about the core-libs-dev mailing list