Skip to content

Commit

Permalink
FileChooser: workaround for crash on Windows with Java 17 32bit (issue
Browse files Browse the repository at this point in the history
  • Loading branch information
DevCharly committed Nov 5, 2021
1 parent e49459f commit 44d8545
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,20 @@ public Dimension getMinimumSize( JComponent c ) {

@Override
public FileView getFileView( JFileChooser fc ) {
return fileView;
return doNotUseSystemIcons() ? super.getFileView( fc ) : fileView;
}

@Override
public void clearIconCache() {
fileView.clearIconCache();
if( doNotUseSystemIcons() )
super.clearIconCache();
else
fileView.clearIconCache();
}

private boolean doNotUseSystemIcons() {
// Java 17 32bit craches on Windows when using system icons
return SystemInfo.isWindows && SystemInfo.isJava_17_orLater && !SystemInfo.isX86_64;
}

//---- class FlatFileView -------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class SystemInfo
public static final boolean isJava_9_orLater;
public static final boolean isJava_11_orLater;
public static final boolean isJava_15_orLater;
public static final boolean isJava_17_orLater;

// Java VMs
public static final boolean isJetBrainsJVM;
Expand Down Expand Up @@ -82,6 +83,7 @@ public class SystemInfo
isJava_9_orLater = (javaVersion >= toVersion( 9, 0, 0, 0 ));
isJava_11_orLater = (javaVersion >= toVersion( 11, 0, 0, 0 ));
isJava_15_orLater = (javaVersion >= toVersion( 15, 0, 0, 0 ));
isJava_17_orLater = (javaVersion >= toVersion( 17, 0, 0, 0 ));

// Java VMs
isJetBrainsJVM = System.getProperty( "java.vm.vendor", "Unknown" )
Expand Down

0 comments on commit 44d8545

Please sign in to comment.