Not exactly game related, but I was looking into a problem with a preference dialog in my application taking a long time to come up after the user selected the menu item. At the moment I construct the UI panels and dialog every time the preference option is selected. Part of the preference panels construct JFileChoosers to be shown later if the user hits a browse button to change some config files. The JFileChooser is constructed but never shown.
When using NB 5 RC2 Profiler to profile the construction of my preference UI the method “sun.awt.shell.Win32ShellFolder2.hasAttribute(int)” takes 55% of the time! It is invoked 6030 times! Taking a total of just over 2 seconds according to the profiler!
What the heck is going on? 6030 invocations??? The actual number of files that the JFileChooser would even need to “look at” (even though it has no reason I can think of for scanning anything on the file system until it is actually shown) would be less than one tenth of that number.
Maybe I have 8 JFileChoosers as sun.awt.shell.Win32ShellFolder2.listFiles is invoked 8 times. 6030/8 = 754 but there are WAY less than 754 files “visible” to these JFileChoosers as far as i can tell - it would be more like 150 files when the JFileChooser is first constructed, then 3 or 4 files if the ‘current folder’ is changed during the initialization of the UI. So even if I give it 160 files * 8 JFileChoosers that would be 1280 files to ‘examine’.
This is all tested with Java 6 b68. I know they’ve been working to improve JFileChooser in Java 6… and I thank Sun for the (long overdue) effort… but the bloody thing still sucks chunks, on windows at least. We’ve had numerous complaints about the file chooser from our customers.