RFR: 8265891: (ch) InputStream returned by Channels.newInputStream should override transferTo

Markus KARG github.com+1701815+mkarg at openjdk.java.net
Thu Jun 17 17:03:16 UTC 2021


On Sat, 5 Jun 2021 07:25:44 GMT, Markus KARG <github.com+1701815+mkarg at openjdk.org> wrote:

>> You mean as a source comment or just here in this discussion thread?
>> 
>> In fact it might be better to not add it to a package with is part of the API, but to move it to the `sun` package, which is not, right?
>> 
>> The justification is that I need to refer to this class from `ChannelInputStream::transferTo()` to be able to get hold of this previously anonymous class's inner member "ch", which in turn is key to the whole story of this PR: Using NIO transfer between the channels instead of moving bytes through the JVM's memory.
>
> Will move the class (and the needed utility methods) to the `sun` package to prevent addition to the API. Stay tuned. :-)

`ChannelOutputStream` isn't part of the API anymore as I moved it to the `sun` package by commit https://github.com/openjdk/jdk/pull/4263/commits/b6dc6a7eadb5168531459aa032f169b344cadb47. Thankyou for pointing this out!

>> Moved I/O operations into the `for` statement by https://github.com/openjdk/jdk/pull/4263/commits/562b1023e62c4ff0a36e55ebc119cee6fb69809c.
>
> Correctly positioning channel in case of exception by https://github.com/openjdk/jdk/pull/4263/commits/ed49098a4712bf23cb6d218c27695717ba3312c2.

Honestly, for me the code looks perfectly comprehensible now, so I actually do not know what to simplify any further (besides adjusting to personal code style likes or dislikes). If there actually *is* something hard to read or understand, please don't hesitate to express your detailed concerns and/or propose an actual change. I will be happy to adopt it in this PR.

>> Uhm... Maybe this is a dumb beginner's question, but: What is "the TL buffer cache"?
>
> I think I found what you mean and will use it: https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/sun/nio/ch/Util.java#L221

Done in https://github.com/openjdk/jdk/pull/4263/commits/8f589867154f8bc22ca6f6bb7a26d7ae841fe714. Thank you!

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

PR: https://git.openjdk.java.net/jdk/pull/4263


More information about the core-libs-dev mailing list