FULL PRODUCT VERSION :
java version "1.6.0_10-rc"
Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b28)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
If a JFileChooser is shown after a UI update just after rescanCurrentDirectory() is called, the EDT will sometimes lock up.
This report is identical to 6741372 except that in the sample code, everything is wrapped in a SwingUtilities.invokeLater(). Note that the The invokerLater() around dg.setVisible() (mentioned as strange in the evaluation for 6741372) is necessary to cause the lock-up for this particular example.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run code.
Hit "Show Dialog" button.
Close dialog.
Hit "Show Dialog" button again.
If that doesn't work:
Run code.
Hit "Show Dialog" button.
Resize dialog so it fills the screen.
Navigate to a directory with a lot of files in it.
Close dialog.
Hit "Show Dialog" button again.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect the dialog to be shown each time the "Show DIalog" button is hit.
ACTUAL -
The application will sometimes lock up.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Thread dump during lock-up:
2008-08-29 07:01:36
Full thread dump Java HotSpot(TM) Client VM (11.0-b15 mixed mode, sharing):
"Basic L&F File Loading Thread" prio=6 tid=0x02b2b800 nid=0x8c waiting on condition [0x03d1f000..0x03d1fd14]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x229f6230> (a java.util.concurrent.FutureTask$Sync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:218)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
at sun.awt.shell.Win32ShellFolderManager2$ComInvoker.invoke(Win32ShellFolderManager2.java:495)
at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run0(BasicDirectoryModel.java:221)
at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread.run(BasicDirectoryModel.java:216)
"TimerQueue" daemon prio=6 tid=0x030c8000 nid=0xe18 in Object.wait() [0x03cbf000..0x03cbfb94]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x22a60108> (a javax.swing.TimerQueue)
at javax.swing.TimerQueue.run(TimerQueue.java:236)
- locked <0x22a60108> (a javax.swing.TimerQueue)
at java.lang.Thread.run(Thread.java:619)
"Swing-Shell" daemon prio=6 tid=0x03058800 nid=0xbac waiting for monitor entry [0x0351f000..0x0351fd14]
java.lang.Thread.State: BLOCKED (on object monitor)
at sun.awt.shell.Win32ShellFolder2.isFileSystem(Win32ShellFolder2.java:512)
- waiting to lock <0x229b7190> (a sun.awt.shell.Win32ShellFolder2)
at sun.awt.shell.Win32ShellFolder2.equals(Win32ShellFolder2.java:484)
at java.util.AbstractList.equals(AbstractList.java:507)
at java.util.Vector.equals(Vector.java:925)
- locked <0x22a66ab8> (a java.util.Vector)
at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread$1.call(BasicDirectoryModel.java:314)
at javax.swing.plaf.basic.BasicDirectoryModel$LoadFilesThread$1.call(BasicDirectoryModel.java:221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at sun.awt.shell.Win32ShellFolderManager2$ComInvoker$3.run(Win32ShellFolderManager2.java:458)
at java.lang.Thread.run(Thread.java:619)
"D3D Screen Updater" daemon prio=8 tid=0x0304e000 nid=0x6dc in Object.wait() [0x0328f000..0x0328fd94]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x22f5dab8> (a java.lang.Object)
at sun.java2d.d3d.D3DScreenUpdateManager.run(D3DScreenUpdateManager.java:422)
- locked <0x22f5dab8> (a java.lang.Object)
at java.lang.Thread.run(Thread.java:619)
"DestroyJavaVM" prio=6 tid=0x002a6800 nid=0x230 waiting on condition [0x00000000..0x0090fd4c]
java.lang.Thread.State: RUNNABLE
"AWT-EventQueue-0" prio=6 tid=0x02af7c00 nid=0x878 waiting on condition [0x02fce000..0x02fcfa14]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x229f4608> (a java.util.concurrent.FutureTask$Sync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:218)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
at sun.awt.shell.Win32ShellFolderManager2$ComInvoker.invoke(Win32ShellFolderManager2.java:495)
at sun.awt.shell.Win32ShellFolder2.hasAttribute(Win32ShellFolder2.java:522)
at sun.awt.shell.Win32ShellFolder2.isLink(Win32ShellFolder2.java:739)
- locked <0x229b7190> (a sun.awt.shell.Win32ShellFolder2)
at javax.swing.filechooser.FileSystemView.isFileSystem(FileSystemView.java:281)
at javax.swing.filechooser.FileSystemView.getSystemDisplayName(FileSystemView.java:155)
at javax.swing.plaf.basic.BasicFileChooserUI$BasicFileView.getName(BasicFileChooserUI.java:1157)
at javax.swing.JFileChooser.getName(JFileChooser.java:1478)
at sun.swing.FilePane$FileRenderer.getListCellRendererComponent(FilePane.java:1325)
at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1349)
at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1299)
at javax.swing.plaf.basic.BasicListUI.getPreferredSize(BasicListUI.java:566)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1632)
at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:769)
at java.awt.Container.layout(Container.java:1398)
at java.awt.Container.doLayout(Container.java:1387)
at java.awt.Container.validateTree(Container.java:1485)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validateTree(Container.java:1491)
at java.awt.Container.validate(Container.java:1457)
- locked <0x22eae220> (a java.awt.Component$AWTTreeLock)
at java.awt.Dialog.conditionalShow(Dialog.java:893)
- locked <0x22eae220> (a java.awt.Component$AWTTreeLock)
at java.awt.Dialog.show(Dialog.java:1019)
at java.awt.Component.show(Component.java:1447)
at java.awt.Component.setVisible(Component.java:1400)
at java.awt.Window.setVisible(Window.java:824)
at java.awt.Dialog.setVisible(Dialog.java:986)
at JFileChooserBug11$1$1$1.setVisible(JFileChooserBug11.java:33)
at JFileChooserBug11$1$1$2.run(JFileChooserBug11.java:46)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
"AWT-Windows" daemon prio=6 tid=0x02abcc00 nid=0xfc4 runnable [0x02f3f000..0x02f3fa94]
java.lang.Thread.State: RUNNABLE
at sun.awt.windows.WToolkit.eventLoop(Native Method)
at sun.awt.windows.WToolkit.run(WToolkit.java:291)
at java.lang.Thread.run(Thread.java:619)
"AWT-Shutdown" prio=6 tid=0x02abb400 nid=0xa0c in Object.wait() [0x02eef000..0x02eefb14]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x22ea8e00> (a java.lang.Object)
at java.lang.Object.wait(Object.java:485)
at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:259)
- locked <0x22ea8e00> (a java.lang.Object)
at java.lang.Thread.run(Thread.java:619)
"Java2D Disposer" daemon prio=10 tid=0x02aba000 nid=0x468 in Object.wait() [0x02e9f000..0x02e9fb94]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x22ea8e90> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
- locked <0x22ea8e90> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
at sun.java2d.Disposer.run(Disposer.java:125)
at java.lang.Thread.run(Thread.java:619)
"Low Memory Detector" daemon prio=6 tid=0x02a71400 nid=0xd24 runnable [0x00000000..0x00000000]
java.lang.Thread.State: RUNNABLE
"CompilerThread0" daemon prio=10 tid=0x02a6b400 nid=0xd10 waiting on condition [0x00000000..0x02d1f940]
java.lang.Thread.State: RUNNABLE
"Attach Listener" daemon prio=10 tid=0x02a69c00 nid=0x5cc waiting on condition [0x00000000..0x00000000]
java.lang.Thread.State: RUNNABLE
"Signal Dispatcher" daemon prio=10 tid=0x02a68800 nid=0xae8 runnable [0x00000000..0x00000000]
java.lang.Thread.State: RUNNABLE
"Finalizer" daemon prio=8 tid=0x02a60400 nid=0xbb4 in Object.wait() [0x02c2f000..0x02c2fa94]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x22ea90c0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
- locked <0x22ea90c0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
"Reference Handler" daemon prio=10 tid=0x02a5f000 nid=0xe0c in Object.wait() [0x02bdf000..0x02bdfb14]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x22ea8b78> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:485)
at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
- locked <0x22ea8b78> (a java.lang.ref.Reference$Lock)
"VM Thread" prio=10 tid=0x02a5d400 nid=0xce0 runnable
"VM Periodic Task Thread" prio=10 tid=0x02a7b800 nid=0x1b4 waiting on condition
JNI global references: 1146
REPRODUCIBILITY :
This bug can be reproduced often.
---------- BEGIN SOURCE ----------
import java.awt.event.*;
import javax.swing.*;
public class JFileChooserBug11 {
static JFileChooser fc;
static JDialog dg;
public static void main(String args[]) {
SwingUtilities.invokeLater(
new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
}
catch (Exception e) {
}
JDialog dialog = new JDialog();
JButton button = new JButton("Show Dialog");
button.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (dg == null) {
dg =
new JDialog() {
public void setVisible(boolean visible) {
fc.rescanCurrentDirectory();
super.setVisible(visible);
}
};
fc = new JFileChooser();
dg.add(fc);
dg.pack();
}
else {
SwingUtilities.updateComponentTreeUI(dg);
}
SwingUtilities.invokeLater(
new Runnable() {
public void run() {
dg.setVisible(true);
} });
}
});
dialog.add(button);
dialog.pack();
dialog.setVisible(true);
}
});
}
}
---------- END SOURCE ----------
FYI, NetBeans users faced system locks with very similar thread dump. Maybe it's not exactly the same case, as "Swing-Shell" thread claims to be runnable, so it doesn't look like real deadlock, but according to users system really locks up. Please see thread dumps and more information at http://www.netbeans.org/issues/show_bug.cgi?id=132961 thank you.