Files.copy does userspace copies but FileChannel uses sendfile

Max Kanat-Alexander mkanat at google.com
Tue Oct 11 23:30:21 UTC 2016


java.nio.file.Files.copy uses this code, ultimately, to copy files:

http://hg.openjdk.java.net/jdk9/dev/jdk/file/tip/src/
java.base/unix/native/libnio/fs/UnixCopyFile.c

I was surprised that that didn't use sendfile when it's available. I was
even more surprised that there is already another copying implementation in
the JDK that _does_ use sendfile:

http://hg.openjdk.java.net/jdk9/dev/jdk/file/b909daf8fdbc/src/java.base/
unix/native/libnio/ch/FileChannelImpl.c#l164

Should these be merged? Or should the Java-side implementation of
Files.copy be changed to use FileChannel underneath?

-Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20161011/523a1287/attachment.html>


More information about the nio-dev mailing list