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

XMLWordPrintable

    • Type: CSR
    • Resolution: Unresolved
    • Priority: P4
    • 26
    • Component/s: core-libs
    • None
    • behavioral
    • low
    • The risk should be low as applications setting this property would be doing so to obtain the legacy behavior.
    • Java API
    • SE

      Summary

      Add a system property jdk.io.File.failIfEmptyPath which when true will cause various java.io.File methods to revert to their behavior prior to JDK-8024695 with respect to the empty path.

      Problem

      The commit which resolved JDK-8024695 caused a number of failures in JDK 25 in external libraries which were relying on observable legacy inconsistent, undocumented behavior of a java.io.File which was created from an empty path. The File class was changed to consider an empty pathname string as being equivalent to the current working directory. This resulted in applications depending on those libraries encountering errors they could not circumvent.

      Solution

      Add a system property jdk.io.File.failIfEmptyPath to make java.io.File handle the empty path as it did prior to JDK 25.

      Specification

      There is no specification change. The system property, if set, merely causes access to the current directory (as implied by an empty pathname string) to fail.

            Assignee:
            Brian Burkhalter
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: