-
Bug
-
Resolution: Unresolved
-
P2
-
8, 25
-
Fix Understood
When a File object is instantiated using an empty string (new File("")), it resolves to the current working directory.
As per the "java.io.File" class level specification "Accessing a file with the empty abstract pathname is equivalent to accessing the current user directory."
However, when listFiles() is invoked on such a File instance with system assertions enabled (-esa), an unexpected AssertionError is thrown.
`-esa` is a standard option https://docs.oracle.com/en/java/javase/24/docs/specs/man/java.html#standard-options-for-java
This behavior is observed only when system assertions are turned on, suggesting that there's an internal assertion in the JDK code path (likely in java.io.File or related native code) that fails under this scenario.
Sample code :
File file = new File(""); // empty path
File[] files = file.listFiles(); // cause AssertionError
=== possible cause ===
private File(String child, File parent) {
assert parent.path != null;
** assert (!parent.path.isEmpty());
As per the "java.io.File" class level specification "Accessing a file with the empty abstract pathname is equivalent to accessing the current user directory."
However, when listFiles() is invoked on such a File instance with system assertions enabled (-esa), an unexpected AssertionError is thrown.
`-esa` is a standard option https://docs.oracle.com/en/java/javase/24/docs/specs/man/java.html#standard-options-for-java
This behavior is observed only when system assertions are turned on, suggesting that there's an internal assertion in the JDK code path (likely in java.io.File or related native code) that fails under this scenario.
Sample code :
File file = new File(""); // empty path
File[] files = file.listFiles(); // cause AssertionError
=== possible cause ===
private File(String child, File parent) {
assert parent.path != null;
** assert (!parent.path.isEmpty());
- relates to
-
JDK-8024695 new File("").exists() returns false whereas it is the current working directory
-
- Resolved
-
-
JDK-8346673 new File("").exists() returns false whereas it is the current working directory
-
- Closed
-
- links to
-
Review(master) openjdk/jdk/26224