On Tue, 15 Jul 2025 17:36:22 GMT, Brian Burkhalter <b...@openjdk.org> wrote:
>> Changes to address `File.listFiles` invoked on an empty path. This fixes an >> oversight in #22821. > > Brian Burkhalter has updated the pull request incrementally with one > additional commit since the last revision: > > 8361587: Fix mkdirs sub-test Hello Brian, I'm late to this discussion. I think there are a couple of more places in this code which need attention. The private `File` constructor which has this `assert` gets invoked from 3 different `File.listFiles()` methods. One of them has now been fixed in this PR. However, 2 other `listFiles()` methods continue to exhibit this issue. I updated the `test/jdk/java/io/File/EmptyPath.java` with a couple of more test methods: diff --git a/test/jdk/java/io/File/EmptyPath.java b/test/jdk/java/io/File/EmptyPath.java index d0c9beddc08..b747c61f5d1 100644 --- a/test/jdk/java/io/File/EmptyPath.java +++ b/test/jdk/java/io/File/EmptyPath.java @@ -28,8 +28,10 @@ */ import java.io.File; +import java.io.FileFilter; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.FilenameFilter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.FileStore; @@ -242,6 +244,19 @@ public void listFiles() throws IOException { assertEquals(nioSet, ioSet); } + + @Test + public void listFiles2() throws IOException { + final File f = new File(""); + final File[] files = f.listFiles((FileFilter) null); + } + + @Test + public void listFiles3() throws IOException { + final File f = new File(""); + final File[] files = f.listFiles((FilenameFilter) null); + } + These 2 new test methods continue to fail against mainline master which has the changes integrated from this PR: java.lang.AssertionError at java.base/java.io.File.<init>(File.java:267) at java.base/java.io.File.listFiles(File.java:1212) at EmptyPath.listFiles2(EmptyPath.java:251) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at java.base/java.util.ArrayList.forEach(ArrayList.java:1604) at java.base/java.util.ArrayList.forEach(ArrayList.java:1604) FAILED EmptyPath::listFiles2 'listFiles2()' [2ms] java.lang.AssertionError at java.base/java.io.File.<init>(File.java:267) at java.base/java.io.File.listFiles(File.java:1180) at EmptyPath.listFiles3(EmptyPath.java:257) at java.base/java.lang.reflect.Method.invoke(Method.java:565) at java.base/java.util.ArrayList.forEach(ArrayList.java:1604) at java.base/java.util.ArrayList.forEach(ArrayList.java:1604) FAILED EmptyPath::listFiles3 'listFiles3()' [0ms] ------------- PR Comment: https://git.openjdk.org/jdk/pull/26224#issuecomment-3077737570