JDK 10 RFR of 8180767: A return value of zero from java.io.File#lastModified() is ambiguous

Brian Burkhalter brian.burkhalter at oracle.com
Mon May 22 20:22:29 UTC 2017


https://bugs.openjdk.java.net/browse/JDK-8180767
http://cr.openjdk.java.net/~bpb/8180767/webrev.00/

java.io.File#lastModified() returns zero if the file in question does not exist. If however the file does exist and by some fantastic improbability has a last-modified time equal to the epoch, then a caller literally following the specification verbiage would interpret the returned value of zero as signifying that the file does not exist. It would probably be ideal to throw a FileNotFoundException when the file does not exist, but instead here we propose to return unity (1) instead of zero when the last-modified time of the file equals the epoch.

Note that this webrev is with respect to the one for [1] which is currently pending CCC approval, and is shown in the webrev in the JDK 9 tree. As it contains code changes, it would however be pushed to JDK 10 after the patch for [1] has been pushed and eventually migrated into the JDK 10 repository.

Thanks,

Brian

[1] http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-May/047787.html


More information about the core-libs-dev mailing list