On Wed, 26 May 2021 17:40:44 GMT, Phil Race <p...@openjdk.org> wrote:

>> src/java.desktop/share/classes/javax/swing/filechooser/FileSystemView.java 
>> line 300:
>> 
>>> 298: 
>>> 299:         if(!f.exists()) {
>>> 300:             return null;
>> 
>> Shall it throw `FileNotFoundException` or `IllegalArgumentException` if the 
>> file doesn't exist?
>> It could more convenient to return `null` rather than catch an exception.
>> 
>> The space is missing between if and the opening parenthesis.
>
> It definitely should not be IAE. But FNFE is a reasonable idea.
> However it changes the usage since it is a checked exception.
> I'm on the fence and could go either way.

The older similar method, `getSystemIcon(File f)`, returns `null` if the file 
doesn't exist. It could make sense to preserve the behaviour from this point of 
view and not to make the user of the API handle FNFE; thus the new method could 
easily be used instead.

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

PR: https://git.openjdk.java.net/jdk/pull/2875

Reply via email to