United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7124363 [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer
7124363 : [macosx] ClassCastException: CFileDialog cannot be cast to LWWindowPeer

Details
Type:
Bug
Submit Date:
2011-12-23
Status:
Closed
Updated Date:
2013-02-12
Project Name:
JDK
Resolved Date:
2012-03-23
Component:
client-libs
OS:
os_x,generic
Sub-Component:
java.awt
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7,7u4,8
Fixed Versions:
7u4

Related Reports
Backport:
Duplicate:
Duplicate:

Sub Tasks

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
I guess the fix for jdk 7 is incorrect. I don't understand why we shouldn't accept FiledDialog as a blocker.
                                     
2013-02-12
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.
                                     
2012-02-14
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
                                     
2011-12-23



Hardware and Software, Engineered to Work Together