RFR: 8274112: (fc) Tune FileChannel.transferTo()
Alan Bateman
alanb at openjdk.java.net
Wed Sep 22 13:36:55 UTC 2021
On Wed, 22 Sep 2021 01:25:37 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Please consider this patch which would improve the performance of
> `FileChannel.transferTo()` on macOS and Windows.
src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java line 559:
> 557: int thisFDVal = IOUtil.fdVal(fd);
> 558: int targetFDVal = IOUtil.fdVal(targetFD);
> 559: if (thisFDVal != -1 && targetFDVal != -1 && thisFDVal == targetFDVal)
How can the fd values be -1 here, we must have an issue somewhere else if this happens.
src/java.base/share/classes/sun/nio/ch/IOStatus.java line 42:
> 40: @Native public static final int THROWN = -5; // Exception thrown in JNI code
> 41: @Native public static final int UNSUPPORTED_CASE = -6; // This case not supported
> 42: @Native public static final int UNSUPPORTED_SUBCASE = -7; // This subcase not supported
I think it's way too confusing to introduce an "unsupported subclass", I think we need to find a better solution for this.
src/java.base/windows/native/libnio/ch/FileChannelImpl.c line 177:
> 175: if (WriteFile(dst, &buf, nr, &nw, NULL) == 0) {
> 176: JNU_ThrowIOExceptionWithLastError(env, "WriteFile failed");
> 177: return IOS_THROWN;
If ReadFile or WriteFile fails then I assume we should return tw when > 0.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5623
More information about the nio-dev
mailing list