On Mon, 3 Oct 2022 12:09:26 GMT, Alexey Ivanov <[email protected]> wrote:
>> In other L&F the same problem exist, but NPE is does not occurs because >> previous state check is not done, directly the clicked file is been set. >> https://github.com/openjdk/jdk/blob/ccc1d3169691d066c08e294f5d989b007bfab114/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java#L1328 > >> Well, the logic there tries to prevent the current directory from becoming >> `null`. Yet it traverses up the tree: >> >> https://github.com/openjdk/jdk/blob/ccc1d3169691d066c08e294f5d989b007bfab114/src/java.desktop/share/classes/javax/swing/JFileChooser.java#L603-L607 >> >> Probably, if `dir` becomes `null` in the end, it should resort to its >> default behaviour: `getFileSystemView().getDefaultDirectory()`. Or not >> change at all? > > This behaviour is specified. > https://github.com/openjdk/jdk/blob/ccc1d3169691d066c08e294f5d989b007bfab114/src/java.desktop/share/classes/javax/swing/JFileChooser.java#L576-L580 > > Yet it doesn't take into account a custom implementation of `FileSystem` > which does not allow navigating up. It may be a problem in `FileSystem` > implementation. > In other L&F the same problem exist, but NPE is does not occurs because > previous state check is not done, directly the clicked file is been set. > > https://github.com/openjdk/jdk/blob/ccc1d3169691d066c08e294f5d989b007bfab114/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java#L1328 Maybe it's the way to go for Metal too? I mean call `setCurrentDirectory` unconditionally. What do other L&Fs do? ------------- PR: https://git.openjdk.org/jdk/pull/10485
