On Tue, 10 Mar 2026 20:05:48 GMT, Kevin Rushforth <[email protected]> wrote:

>> what do other people think?  @hjohn @mstr2 @nlisker @crschnick
>
> That's a fair point. Let's continue the discussion. I am not opposed to 
> changing the behavior as long as we've thought through all the consequences.

I think Andy is right here, we're dealing with IO. Whatever directory you set 
can change at a moments notice (if it was correct to begin with). An 
`IllegalArgumentException` should be for errors that can be 100% avoided and so 
are always programming mistakes. However, in this case, even if I verify that 
the `File` I set is a directory, and accessible, etc, this may not be the case 
any more when the dialog is shown. It is not something you can blame on the 
programmer when it inevitably fails.

The right approach then depends a bit on how crucial this initial directory 
really is. If it must be there and it can't be anything else, then 
`IOException` (which it was when thrown originally) would be appropriate to 
indicate there may be a failure that cannot reasonably be always avoided 
beforehand with better code. This is good because you can't miss it if you 
forget to read docs.

However, in this case, being just a file chooser, it would also be appropriate 
to fall back to some directory (perhaps selectable) or do something like 
stripping paths from the given `File` until a directory is found that does 
exist and is accessible.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2101#discussion_r2914753103

Reply via email to