On Fri, 8 Dec 2023 17:54:21 GMT, Vladimir Sitnikov <vsitni...@openjdk.org> 
wrote:

>> src/java.base/share/classes/java/io/OutputStream.java line 212:
>> 
>>> 210:      * @return true if the argument of {@link #write(byte[])}} and 
>>> {@link #write(byte[], int, int)}} needn't be copied
>>> 211:      */
>>> 212:     boolean trusted() {
>> 
>> This is a strange construction. Any subclass could simply implement this as 
>> `return true;`. Where is the guard against this, and why not doing it that 
>> way?
>
> Technically speaking, `OutputStream` is an `abstract class`, so this 
> declaration of `boolean trusted()` is a package-protected method that will be 
> visible and overridable only within JDK itself.
> However, I agree it looks suspicious.

The comment on this method doesn't look right. The issue for BAIS is that its 
lifetime may be different to the byte[] that it wraps, think about use after 
the BAIS has been discarded. You don't want a sink keeping a reference to the 
byte[] even if it doesn't scribble on it.

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

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

Reply via email to