Summary
On Linux, modify java.nio.file.attributes.BasicFileAttributes.creationTime()
to return the last modified time instead of 0, the epoch, if the birth timestamp of the file is unavailable.
Problem
The change which resolved JDK-8316304 added support for obtaining the file creation time from the birth timestamp. Prior to this change, the last modified time had been returned for the creation time. After this change, if the birth timestamp is unavailable, for example if it is not supported by the file system even though the operating system supports it, then the epoch (0) is returned for the creation time. This can, and in fact was observed to, cause problems in situations which relied on the old behavior.
Solution
Return the last modified time instead of zero for the creation time when the birth timestamp is unavailable.
Specification
There are no changes to the specification of BasicFileAttributes.creationTime()
, but its current wording is provided here for convenience. Note that both behaviors, returning the last modified time or the epoch, are within the bounds of the specification.
Returns the creation time. The creation time is the time that the file was created.
If the file system implementation does not support a time stamp to indicate the time when the file was created then this method returns an implementation specific default value, typically the last-modified-time or a FileTime representing the epoch (1970-01-01T00:00:00Z).
- csr of
-
JDK-8338696 (fs) BasicFileAttributes.creationTime() falls back to epoch if birth time is unavailable (Linux)
- Resolved
- relates to
-
JDK-8316304 (fs) Add support for BasicFileAttributes.creationTime() for Linux
- Resolved