RFR: 8370216: Fix of new File("").exists() causes undefined behavior in libraries

Brian Burkhalter bpb at openjdk.org
Thu Nov 6 17:24:55 UTC 2025


On Wed, 5 Nov 2025 18:14:44 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Add a system property, `jdk.io.File.failIfEmptyPath`, which when `true` reverts to legacy, pre-JDK 25 behavior, as to how `java.io.File` handles an empty pathname string.

The implementation modification which resolved [JDK-8024695](https://bugs.openjdk.org/browse/JDK-8024695) caused a `java.io.File` created from the empty string `""` to be treated as if the file was created from the pathname string of the current working directory, `System.getProperty("user.dir")`. This change caused failures in code which relied on the inconsistent, undocumented behavior.

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

PR Comment: https://git.openjdk.org/jdk/pull/28158#issuecomment-3492681612


More information about the core-libs-dev mailing list