Summary
Change the specification of java.io.File
to make explicit that a File
with an empty abstract pathname is equivalent to a File
with the pathname of the current user directory ("."
).
Problem
For the empty abstract pathname ""
, if a File
is created as File f = new File("")
, then many methods of File
do not exhibit the behavior that would be expected or would be the equivalent of that of the corresponding methods of java.nio.file.Path
, java.nio.file.Files
, and java.nio.file.FileStore
, where such equivalents exist.
Solution
Add a sentence to the documentation of java.io.File
clarifying the behavior for the empty abstract pathname, and change the relevant methods' behaviors to match.
Specification
--- a/src/java.base/share/classes/java/io/File.java
+++ b/src/java.base/share/classes/java/io/File.java
@@ -56,7 +56,8 @@
* case of Microsoft Windows UNC pathnames, a hostname. Each subsequent name
* in an abstract pathname denotes a directory; the last name may denote
* either a directory or a file. The <em>empty</em> abstract pathname has no
- * prefix and an empty name sequence.
+ * prefix and an empty name sequence. Accessing a file with the empty abstract
+ * pathname is equivalent to accessing the current user directory.
*
* <p> The conversion of a pathname string to or from an abstract pathname is
* inherently system-dependent. When an abstract pathname is converted into a
- csr of
-
JDK-8024695 new File("").exists() returns false whereas it is the current working directory
-
- Resolved
-