RFR: 8362429: AssertionError in File.listFiles(FileFilter | FilenameFilter) [v2]
Brian Burkhalter
bpb at openjdk.org
Wed Jul 16 19:08:40 UTC 2025
On Wed, 16 Jul 2025 18:26:51 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8362429: Add list(FilenameFilter) and toURL()
>
> src/java.base/share/classes/java/io/File.java line 1227:
>
>> 1225: File f = new File(s, this);
>> 1226: if ((filter == null) || filter.accept(f))
>> 1227: files.add(f);
>
> Rather than duplicating the loop, it could be changed to introduce `boolean isEmpty = path.isEmpty` and then the `f` can be created with `File f = isEmpty ? new File(s) : new File(this, s);` It should be a bit cleaner.
I had rejected that in the case of the parameter-less `listFiles` to avoid a ternary operator in each loop iteration but it _is_ cleaner. Will update.
> What would you think about test a non-null filter too?
Okay.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26353#discussion_r2211324685
PR Review Comment: https://git.openjdk.org/jdk/pull/26353#discussion_r2211325168
More information about the core-libs-dev
mailing list