JDK-8046391 : Hang displaying JFileChooser with Windows L&F
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 9
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-06-09
  • Updated: 2014-08-28
  • Resolved: 2014-06-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b22Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
Subsequent to the JDK 9 fix for 8039383: NPE when changing Windows theme
a hang is seen in SwingSet2 when displaying the JFileChooser in Win L&F.

This trivial program is enough to reproduce it.
import javax.swing.*;

public class Freeze {
  public static void main(String args[]) {
     SwingUtilities.invokeLater(new Runnable() {
        public void run() {
          JFrame f = new JFrame("Freeze");
          f.setSize(100,100);
          f.show();
          try {
             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          } catch (Exception e) {
          }
          JFileChooser fileChooser = new JFileChooser(); 
          System.out.println("chooser="+fileChooser);
       }
     });
   }

}
Comments
Regression test to this hang is provided under JDK-8046559.
11-07-2014

The fix to JDK-8039383 and JDK-8046239 was backed out from the repository. See JDK-8046559 for the working fix.
09-07-2014

JFileChooser in Windows L&F creates the places bar. This bar is a specialized toolbar which uses theme "placesbar::TOOLBAR". To get the HTHEME handle to such theme, ThemeReader.getThemeImpl (holds write lock) uses SetWindowTheme function from Win32 API; this call results in WM_THEMECHANGED, and therefore WToolkit.windowsSettingChange(). The latter calls ThemeReader.flush() which also requires write lock. This is the reason why a deadlock occurs only when using JFileChooser().
10-06-2014

This hang is the deadlock between Windows Toolkit thread and AWT Event Queue thread. The fix to JDK-8039383 moved the call to wprops.getProperties() to the toolkit thread; in its turn WDesktopProperties.getProperties calls ThemeReader.flush() to clear the cached theme data. Name: AWT-Windows State: WAITING on java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync@effd0d owned by: AWT-EventQueue-0 Total blocked: 0 Total waited: 6 Stack trace: sun.misc.Unsafe.park(Native Method) java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836) java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870) java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1199) java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:942) sun.awt.windows.ThemeReader.flush(ThemeReader.java:67) sun.awt.windows.WDesktopProperties.getProperties(WDesktopProperties.java:244) - locked sun.awt.windows.WDesktopProperties@18072a0 sun.awt.windows.WToolkit.getWProps(WToolkit.java:966) - locked sun.awt.windows.WToolkit@498bd6 sun.awt.windows.WToolkit.windowsSettingChange(WToolkit.java:938) sun.awt.windows.WToolkit.eventLoop(Native Method) sun.awt.windows.WToolkit.run(WToolkit.java:305) java.lang.Thread.run(Thread.java:745) Name: AWT-EventQueue-0 State: RUNNABLE Total blocked: 54 Total waited: 941 Stack trace: sun.awt.windows.ThemeReader.setWindowTheme(Native Method) sun.awt.windows.ThemeReader.getThemeImpl(ThemeReader.java:93) sun.awt.windows.ThemeReader.getTheme(ThemeReader.java:113) sun.awt.windows.ThemeReader.getEnum(ThemeReader.java:189) com.sun.java.swing.plaf.windows.XPStyle.getTypeEnumName(XPStyle.java:150) com.sun.java.swing.plaf.windows.XPStyle.getBorder(XPStyle.java:276) - locked com.sun.java.swing.plaf.windows.XPStyle@34a2a com.sun.java.swing.plaf.windows.WindowsToolBarUI.getRolloverBorder(WindowsToolBarUI.java:94) javax.swing.plaf.basic.BasicToolBarUI.setBorderToRollover(BasicToolBarUI.java:692) javax.swing.plaf.basic.BasicToolBarUI$Handler.componentAdded(BasicToolBarUI.java:1131) java.awt.Container.processContainerEvent(Container.java:2270) java.awt.Container.processEvent(Container.java:2241) java.awt.Component.dispatchEventImpl(Component.java:4892) java.awt.Container.dispatchEventImpl(Container.java:2302) java.awt.Component.dispatchEvent(Component.java:4714) java.awt.Container.addImpl(Container.java:1146) - locked java.awt.Component$AWTTreeLock@1a86196 javax.swing.JToolBar.addImpl(JToolBar.java:581) java.awt.Container.add(Container.java:425) sun.swing.WindowsPlacesBar.<init>(WindowsPlacesBar.java:136) com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFolder(WindowsFileChooserUI.java:508) com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(WindowsFileChooserUI.java:213) javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserUI.java:173) com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(WindowsFileChooserUI.java:150) javax.swing.JComponent.setUI(JComponent.java:665) javax.swing.JFileChooser.updateUI(JFileChooser.java:1837) javax.swing.JFileChooser.setup(JFileChooser.java:372) javax.swing.JFileChooser.<init>(JFileChooser.java:344) javax.swing.JFileChooser.<init>(JFileChooser.java:297) FileChooserDemo.createFileChooser(FileChooserDemo.java:129) FileChooserDemo$2.actionPerformed(FileChooserDemo.java:148) javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2023) javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2347) javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:403) javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:260) javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) java.awt.Component.processMouseEvent(Component.java:6536) javax.swing.JComponent.processMouseEvent(JComponent.java:3323) java.awt.Component.processEvent(Component.java:6301) java.awt.Container.processEvent(Container.java:2244) java.awt.Component.dispatchEventImpl(Component.java:4892) java.awt.Container.dispatchEventImpl(Container.java:2302) java.awt.Component.dispatchEvent(Component.java:4714) java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4908) java.awt.LightweightDispatcher.processMouseEvent(Container.java:4543) java.awt.LightweightDispatcher.dispatchEvent(Container.java:4472) java.awt.Container.dispatchEventImpl(Container.java:2288) java.awt.Window.dispatchEventImpl(Window.java:2739) java.awt.Component.dispatchEvent(Component.java:4714) java.awt.EventQueue.dispatchEventImpl(EventQueue.java:751) java.awt.EventQueue.access$500(EventQueue.java:97) java.awt.EventQueue$3.run(EventQueue.java:702) java.awt.EventQueue$3.run(EventQueue.java:696) java.security.AccessController.doPrivileged(Native Method) java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86) java.awt.EventQueue$4.run(EventQueue.java:724) java.awt.EventQueue$4.run(EventQueue.java:722) java.security.AccessController.doPrivileged(Native Method) java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) java.awt.EventQueue.dispatchEvent(EventQueue.java:721) java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
10-06-2014