On Wed, 16 Jul 2025 19:05:30 GMT, Brian Burkhalter <b...@openjdk.org> wrote:

>> 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.

So changed in cfd494f.

>> test/jdk/java/io/File/EmptyPath.java line 248:
>> 
>>> 246:         listFiles(x -> x.listFiles((FilenameFilter)null));
>>> 247:     }
>>> 248: 
>> 
>> What would you think about test a non-null filter too?
>
>> What would you think about test a non-null filter too?
> 
> Okay.

Add `listFiles` tests for non-null `FileFilter` and `FilenameFilter` in cfd494f.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26353#discussion_r2211361076
PR Review Comment: https://git.openjdk.org/jdk/pull/26353#discussion_r2211364676

Reply via email to