JDK-7124363 : [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7,7u4,8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,os_x
  • CPU: generic,x86
  • Submitted: 2011-12-23
  • Updated: 2013-10-02
  • Resolved: 2012-03-23
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 7
7u4 b13Fixed
Related Reports
Duplicate :  
Duplicate :  
Description
http://java.net/jira/browse/MACOSX_PORT-389 submitted 2011/09/12 by Yuri Nesterenko
Failing code displays an application modal FileDialog (with a null frame owner). It should stay on top of a Window when setVisible(true) in called on the Window. 
The same exception we have for Toolkit modal FileDialog in similar circumstances etc.
Stack trace excerpt below:
<span class=&quot;error&quot;>&#91;2011-09-08T19:56:54.45&#93;</span> Exception in thread &quot;AWT-EventQueue-0&quot; java.lang.ClassCastException: sun.lwawt.macosx.CFileDialog cannot be cast to sun.lwawt.LWWindowPeer
<span class=&quot;error&quot;>&#91;2011-09-08T19:56:54.45&#93;</span>        at sun.lwawt.LWWindowPeer.setModalBlocked(LWWindowPeer.java:372)
<span class=&quot;error&quot;>&#91;2011-09-08T19:56:54.45&#93;</span>        at java.awt.Window.setModalBlocked(Window.java:1497)
<span class=&quot;error&quot;>&#91;2011-09-08T19:56:54.45&#93;</span>        at java.awt.Dialog.blockWindow(Dialog.java:1545)
<span class=&quot;error&quot;>&#91;2011-09-08T19:56:54.45&#93;</span>        at java.awt.Dialog.checkShouldBeBlocked(Dialog.java:1589)
<span class=&quot;error&quot;>&#91;2011-09-08T19:56:54.45&#93;</span>        at java.awt.Window.show(Window.java:1038)
<span class=&quot;error&quot;>&#91;2011-09-08T19:56:54.45&#93;</span>        at java.awt.Component.show(Component.java:1650)
<span class=&quot;error&quot;>&#91;2011-09-08T19:56:54.45&#93;</span>        at java.awt.Component.setVisible(Component.java:1602)
<span class=&quot;error&quot;>&#91;2011-09-08T19:56:54.45&#93;</span>        at java.awt.Window.setVisible(Window.java:1011)

Comments
The FileDialog is application-modal and it is ensured by the native system, so it is unnecessary to set the CFileDialog peer as a blocker. So, I believe the fix from the JDK7 is acceptable. I will forward-port it.
25-09-2013

I guess the fix for jdk 7 is incorrect. I don't understand why we shouldn't accept FiledDialog as a blocker.
12-02-2013

EVALUATION In LWWindowPeer.setModalBlocked(Dialog, boolean) method we falsely assume that all the dialogs have peer that is extension of the LWWindowPeer which is not true for FileDialog and couple of other dialogs. Adding an instanceof check before assigning sounds like a good idea. After the check is added all tests pass.
14-02-2012

EVALUATION Author: Yuri Nesterenko Date: 12/Sep/11 09:12 AM Build: b207 AWT_Modality/Automated/setVisible/FileDialog/ApplicationModal AWT_Modality/Automated/setVisible/FileDialog/ToolkitModal AWT_Modality/Automated/FileDialog/ToolkitModalDialog
23-12-2011