On Wed, 29 Nov 2023 11:57:37 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 src/java.base/share/classes/java/io/BufferedInputStream.java line 647: > 645: if (avail > 0) { > 646: // trust all OutputStreams from java.io > 647: if (out.getClass().getPackageName() == > BufferedInputStream.class.getPackageName()) { I don't think Class::getPackageName documents that the returned String is intern so I wonder if the == check will lead to questions and suggestions of a bug. Classes with names starting with "java." can only be defined to the boot or platform class loader (details in the ClassLoader API docs) so you could just check if the package name equals "java.io". ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/16879#discussion_r1409802437