-
Bug
-
Resolution: Unresolved
-
P4
-
17, 21
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
Windows 10
openjdk 21.0.2 2024-01-16 LTS
A DESCRIPTION OF THE PROBLEM :
When you browse a folder with many files on your local disk (e.g. 4000 text files) the JFileChooser is very slow to open this folder. This occurs since Java 17 and is reproducible in 21 as well.
In Java 14, 15 and 16 opening the same folder is much faster.
Opening an example folder with 4000 text files:
Java 17 .. 21 : 7 seconds
Java 14 .. 16 : < 1 second
Running the same test with files on a network share is ever slower and may take minutes.
REGRESSION : Last worked in version 16
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a folder with many files on your local disk, e.g. in Powershell run
PS c:\temp> mkdir c:\temp\many_files
PS c:\temp> cd c:\temp\many_files
PS C:\Temp\many_files> 1..4000 |
>> ForEach-Object {
>> New-Item -Name ('FileNumber_{0}.txt' -f $_) -ItemType 'File'
>> }
2. Run the test case file with Java 17 or later. (Tested with 17 and 21)
Open the file chooser and change into the folder c:\temp\many_files.
In my example this takes 7 seconds.
3. Compare the result with Java 16 and lower (Tested with 14,15 and 16)
In my example it takes less than a second.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The file chooser opens directories with many files as fast as with Java 16
ACTUAL -
The file chooser takes much longer open the directory compared to Java 16 (and below).
---------- BEGIN SOURCE ----------
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
public class TestSwing {
static JFileChooser fc = null;
public static void main(String[] args) throws Exception {
System.out.println("Java version : " + System.getProperty("java.version"));
// Code works with cross platform look and feel
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
JFrame frame = new JFrame();
frame.setSize(new Dimension(400, 400));
JPanel panel = new JPanel();
JButton btn = new JButton("Show");
fc = new JFileChooser();
btn.addActionListener(e -> {
fc.showOpenDialog(frame);
});
panel.add(btn);
frame.add(panel);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
---------- END SOURCE ----------
FREQUENCY : always
Windows 10
openjdk 21.0.2 2024-01-16 LTS
A DESCRIPTION OF THE PROBLEM :
When you browse a folder with many files on your local disk (e.g. 4000 text files) the JFileChooser is very slow to open this folder. This occurs since Java 17 and is reproducible in 21 as well.
In Java 14, 15 and 16 opening the same folder is much faster.
Opening an example folder with 4000 text files:
Java 17 .. 21 : 7 seconds
Java 14 .. 16 : < 1 second
Running the same test with files on a network share is ever slower and may take minutes.
REGRESSION : Last worked in version 16
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a folder with many files on your local disk, e.g. in Powershell run
PS c:\temp> mkdir c:\temp\many_files
PS c:\temp> cd c:\temp\many_files
PS C:\Temp\many_files> 1..4000 |
>> ForEach-Object {
>> New-Item -Name ('FileNumber_{0}.txt' -f $_) -ItemType 'File'
>> }
2. Run the test case file with Java 17 or later. (Tested with 17 and 21)
Open the file chooser and change into the folder c:\temp\many_files.
In my example this takes 7 seconds.
3. Compare the result with Java 16 and lower (Tested with 14,15 and 16)
In my example it takes less than a second.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The file chooser opens directories with many files as fast as with Java 16
ACTUAL -
The file chooser takes much longer open the directory compared to Java 16 (and below).
---------- BEGIN SOURCE ----------
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
public class TestSwing {
static JFileChooser fc = null;
public static void main(String[] args) throws Exception {
System.out.println("Java version : " + System.getProperty("java.version"));
// Code works with cross platform look and feel
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
JFrame frame = new JFrame();
frame.setSize(new Dimension(400, 400));
JPanel panel = new JPanel();
JButton btn = new JButton("Show");
fc = new JFileChooser();
btn.addActionListener(e -> {
fc.showOpenDialog(frame);
});
panel.add(btn);
frame.add(panel);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
---------- END SOURCE ----------
FREQUENCY : always