RFR: 4619075: (ch) newChannel() should return Gathering/ScatteringByteChannel

Joe Darcy darcy at openjdk.java.net
Wed Oct 13 16:47:49 UTC 2021


On Wed, 13 Oct 2021 07:14:21 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Modify `Channels.newChannel(InputStream)` and `Channels.newChannel(OutputStream)` to return `ScatteringByteChannel` and `GatheringByteChannel`, respectively.
>
> src/java.base/share/classes/java/nio/channels/Channels.java line 271:
> 
>> 269:      * @return  A new readable byte channel
>> 270:      */
>> 271:     public static ScatteringByteChannel newChannel(InputStream in) {
> 
> This looks like a binary incompatible change, are you sure that existing code won't fail at runtime with NoSuchMethodError?

Right; covariant overrides are only compatible for instance methods, not static methods.

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

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


More information about the nio-dev mailing list