8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps

Brian Burkhalter brian.burkhalter at oracle.com
Wed Jul 10 20:39:59 UTC 2019

https://bugs.openjdk.java.net/browse/JDK-8181493 <https://bugs.openjdk.java.net/browse/JDK-8181493>

This patch would change:

1) UnixFileAttributeViews.setTimes() to set the access and modification times of a file or directory with nanosecond precision if the system call futimens() [1] is available, and
2) UnixFileAttributes to initialize the creation, last access, and last modifications FileTimes with nanosecond precision.

New methods to support setting the nanosecond resolution access and modification times using futimens() are added to UnixNativeDispatcher. Note that unlike futimes() and lutimes(), futimens() is *not* guaranteed to be present for the _ALLBDS_SOURCE case and so it is looked up using dlsym().

A new test is added to run on Linux, macOS, and Solaris only. On macOS if the file system is HFS+, then the test exits without failing as HFS+ supports a file stamp resolution of only one second. If the macOS file system is APFS, then the test runs through to completion.

Note that setting the creation time as requested in [2] appears problematic and unevenly supported on these Unix variants.



[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html <https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html>
[2] https://bugs.openjdk.java.net/browse/JDK-8151430
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190710/d9b5d020/attachment.html>

More information about the nio-dev mailing list