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

Alan Bateman alanb at openjdk.org
Fri Feb 21 07:44:56 UTC 2025


On Thu, 20 Feb 2025 22:20:04 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.
>
> Brian Burkhalter has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains eight commits:
> 
>  - 8024695: Move getCWD to holder; remove Order from test
>  - Merge
>  - 8024695: Extend and clean up test
>  - 8024695: Fix merge error; improve get*Space tests
>  - Merge
>  - 8024695: Add test of length()
>  - 8024695: Change implementation to work for empty path
>  - 8024695: new File("").exists() returns false whereas it is the current working directory

test/jdk/java/io/File/EmptyPath.java line 121:

> 119:             assertTrue(actual > 0);
> 120:             long ds = Math.abs(expected - actual);
> 121:             assertTrue((double)ds/expected < 0.05);

Are you confident that this tolerance is enough? Every test that has checked space available/used has taken a long time to bed in. For this test then I don't think we need to assert any relationship between the allocated and free space, it really just needs to check that it returns some value for the current directory.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22821#discussion_r1965013880


More information about the core-libs-dev mailing list