RFR: 8024695: new File("").exists() returns false whereas it is the current working directory

Brian Burkhalter bpb at openjdk.org
Tue Jan 28 20:24:24 UTC 2025


On Thu, 19 Dec 2024 00:36:44 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Update the specification of `java.io.File.exists()` to match its behavior, which seems correct in the context of how the empty abstract pathname is documented elsewhere in the class.

Commit 9d6d910 removes the change of specification of `File.exists` and changes the implementation of `File` to treat the empty path `""` as the current directory `"."` where appropriate.

- The test primarily verifies the `File` methods which differed in manual testing for `new File("")` from the equivalent methods of `Path` and `Files` for `Path.of("")`.
- The `lengthUnix` and `lengthWindows` tests could likely be collapsed to just test `File.length` against `Files.size(path)`.
- The `get*Space` checks could instead be against +/-5% of the values returned by the equivalent NIO methods.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/22821#issuecomment-2619980771


More information about the core-libs-dev mailing list