United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6497929 Modal dialogs are added to modalDialogs field several times
JDK-6497929 : Modal dialogs are added to modalDialogs field several times

Details
Type:
Bug
Submit Date:
2006-11-28
Status:
Closed
Updated Date:
2011-03-07
Project Name:
JDK
Resolved Date:
2011-03-07
Component:
client-libs
OS:
generic,windows_xp
Sub-Component:
java.awt
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Backport:
Duplicate:
Relates:

Sub Tasks

Description
Any modal dialog is added to the 'modalDialogs' static field of java.awt.Dialog class in modalShow() method. However, this method is called not only the dialog is really shown, but also when it is unblocked by another modal dialog. This leads to the situation when the dialog is added to the list of modal dialogs several times and prevents it from being GCed.

The test that can be used to demostrate the problem is attached.

                                    

Comments
EVALUATION

Modal dialogs should be tracked more carefully. For example, an additional check may be added to modalShow() to add the dialog to modalDialogs field only if it is not there yet, however there can a better solution.
                                     
2006-11-28
EVALUATION

After some discussion with the AWT team I decided to fix the problem with just moving 'modalDialogs.add(this)' and 'modalDialogs.remove(this)' out from modalShow() and modalHide(). I think this is a more correct solution than just to check if the dialog is already added to the list, because modalShow() and modalHide() methods are responsible only for windows blocking/unblocking, which can be called not only when a dialog is shown/hidden. At the same time 'modalDialogs' field is tightly related with the dialogs showing/hiding, so I suggest to remove it from modalShow()/modalHide().
                                     
2006-11-29



Hardware and Software, Engineered to Work Together