RFR: 8361587: AssertionError in File.listFiles() when path is empty and -esa is enabled

Alan Bateman alanb at openjdk.org
Wed Jul 9 18:19:40 UTC 2025


On Wed, 9 Jul 2025 18:04:08 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Changes to address `File.listFiles` invoked on an empty path. This fixes an oversight in #22821.

test/jdk/java/io/File/EmptyPath.java line 216:

> 214:         List<String> ioNames =
> 215:             Arrays.asList(files).stream().map(f -> f.toString()).toList();
> 216:         Set<String> ioSet = new HashSet(ioNames);

You can simplify this by collecting into the set, e.g.

Set<String> ioSet = Arrays.stream(files)
                .map(File::getName)
                .collect(Collectors.toSet());

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26224#discussion_r2195697480


More information about the core-libs-dev mailing list