JDK-8180767 : A return value of zero from java.io.File#lastModified() is ambiguous
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 10
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • Submitted: 2017-05-22
  • Updated: 2017-06-13
  • Resolved: 2017-06-13
Related Reports
Duplicate :  
Relates :  
Description
The currently public specification of java.io.File#lastModified() as given below is ambiguous if the last-modified time of an actually extant file is exactly the epoch because the return value would per the specification indicate that the file does not exist.

Returns:
    A long value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the file does not exist or if an I/O error occurs
Throws:
    SecurityException - If a security manager exists and its SecurityManager.checkRead(java.lang.String) method denies read access to the file 
Comments
Resolving as a duplicate of JDK-6791812.
13-06-2017

Throwing a FileNotFoundException for a non-existent file would be what most would expect, but this would be an incompatible change with little value. [~rriggs] suggested instead to return unity (1) instead of zero (0) if the file exists and has a last-modified time of exactly the epoch.
22-05-2017