JDK-4936652 : JDialog.setVisible, JDialog.dispose works incorrectly
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 2003-10-13
  • Updated: 2004-09-27
  • Resolved: 2004-09-27
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.
Other
5.0 b28Fixed
Related Reports
Relates :  
Description
ring "-monotype-arial-regular-r-normal--*-140-*-*-p-*-iso8859-1" to type FontStruct
AccessibleJDialog2001: Passed. OKAY
AccessibleJDialog0036: Passed. OKAY
AccessibleJDialog0035: Passed. OKAY
AccessibleJDialog0034: Passed. OKAY
AccessibleJDialog0033: Passed. OKAY
AccessibleJDialog0032: Passed. OKAY
AccessibleJDialog0031: Passed. OKAY
AccessibleJDialog0030: Passed. OKAY
AccessibleJDialog0029: Passed. OKAY
AccessibleJDialog0028: Passed. OKAY
AccessibleJDialog0027: Passed. OKAY
AccessibleJDialog0026: Passed. OKAY
AccessibleJDialog0025: Passed. OKAY
AccessibleJDialog0024: Passed. OKAY
AccessibleJDialog0023: Passed. OKAY
AccessibleJDialog0022: Failed. The method works incorrectly
AccessibleJDialog0021: Passed. OKAY
AccessibleJDialog0020: Passed. OKAY
AccessibleJDialog0019: Passed. OKAY
AccessibleJDialog0018: Passed. OKAY
AccessibleJDialog0017: Passed. OKAY
AccessibleJDialog0016: Passed. OKAY
AccessibleJDialog0015: Passed. OKAY
AccessibleJDialog0014: Passed. OKAY
AccessibleJDialog0013: Passed. OKAY
AccessibleJDialog0012: Passed. OKAY
AccessibleJDialog0011: Passed. OKAY
STATUS:Failed.test cases: 27; passed: 26; failed: 1; first test case failure: AccessibleJDialog0022
result: Failed. test cases: 27; passed: 26; failed: 1; first test case failure: AccessibleJDialog0022


test result: Failed. test cases: 27; passed: 26; failed: 1; first test case failure: AccessibleJDialog0022


======================================================================
###@###.### 2004-09-27
Name: dsR10051			Date: 10/13/2003


Filed By      : SPB JCK team (###@###.###)
JDK           : java full version "1.5.0-beta-b23"
JCK           : 1.5
Platform[s]   : Solaris
switch/Mode   : 
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] :
    api/javax_swing/JDialog/AccessibleJDialog/index.html#AccessibleComponent


Problem description
===================
The methods java.awt.Component.setVisible() and java.awt.Window.dispose() works
incorrectly on javax.swing.JDialog object.
The minimized test demonstrates that
1. JDialog.isVisible returns false while setVisible(true) has been called.
2. deadlock  is possible during setVisible/dispose operations.
    
Minimized test:
===============
------- test01.java -------
import javax.swing.*;
import javax.accessibility.*;

public class test01 {

    public static void main(String[] args) {
        for (int i = 0 ; i <100; i++) {
            System.out.println("i: " + i);
            JDialog o = new JDialog();
            o.setVisible(true);
            if (!o.isVisible()) {
                System.out.println("no visible"); System.out.flush();
            }
            o.setVisible(false);
            if (o.isVisible()) {
                System.out.println("visible"); System.out.flush();
            }
            o.dispose();
        }
        System.exit(0);
    }
}


------- end-of-test01.java -------

Minimized test output:
======================
% java test01
i: 0
...
i: 38
not visible
i: 39
...
i: 61
^\Full thread dump Java HotSpot(TM) Client VM (1.5.0-beta-b23 mixed mode):

"AWT-EventQueue-0" prio=10 tid=0x00262048 nid=0xe waiting for monitor entry [0xf0400000..0xf0401838]
        at java.awt.Container.removeNotify(Container.java:2503)
        - waiting to lock <0xf0c30560> (a java.awt.Component$AWTTreeLock)
        at java.awt.Window$1DisposeAction.run(Window.java:604)
        at java.awt.Window.doDispose(Window.java:617)
        at java.awt.Dialog.doDispose(Dialog.java:625)
        at java.awt.Window.dispose(Window.java:574)
        at java.awt.Window.disposeImpl(Window.java:584)
        at java.awt.Window$1DisposeAction.run(Window.java:598)
        - locked <0xf0c41ec8> (a java.util.Vector)
        at java.awt.Window.doDispose(Window.java:617)
        at java.awt.Window.dispose(Window.java:574)
        at javax.swing.SwingUtilities$SharedOwnerFrame.dispose(SwingUtilities.java:1743)
        at javax.swing.SwingUtilities$SharedOwnerFrame.windowClosed(SwingUtilities.java:1722)
        at java.awt.Window.processWindowEvent(Window.java:1173)
        at javax.swing.JDialog.processWindowEvent(JDialog.java:407)
        at java.awt.Window.processEvent(Window.java:1128)
        at java.awt.Component.dispatchEventImpl(Component.java:3922)
        at java.awt.Container.dispatchEventImpl(Container.java:2009)
        at java.awt.Window.dispatchEventImpl(Window.java:1746)
        at java.awt.Component.dispatchEvent(Component.java:3770)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:214)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

"AWT-Motif" daemon prio=10 tid=0x0023fc20 nid=0xd runnable [0xf0501000..0xf05016b8]
        at sun.awt.motif.MToolkit.run(Native Method)
        at java.lang.Thread.run(Thread.java:549)

"AWT-Shutdown" prio=10 tid=0x0023f840 nid=0xc in Object.wait() [0xf0601000..0xf0601738]
        at java.lang.Object.wait(Native Method)
        - waiting on <0xf0c4c5a8> (a java.lang.Object)
        at java.lang.Object.wait(Object.java:429)
        at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:259)
        - locked <0xf0c4c5a8> (a java.lang.Object)
        at java.lang.Thread.run(Thread.java:549)

"Java2D Disposer" daemon prio=10 tid=0x002007d8 nid=0xb in Object.wait() [0xf0701000..0xf07019b8]
        at java.lang.Object.wait(Native Method)
        - waiting on <0xf0c49f28> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
        - locked <0xf0c49f28> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
        at sun.java2d.Disposer.run(Disposer.java:107)
        at java.lang.Thread.run(Thread.java:549)

"Low Memory Detector" daemon prio=10 tid=0x0012bf28 nid=0x9 runnable [0x00000000..0x00000000]

"CompilerThread0" daemon prio=10 tid=0x0012a5a8 nid=0x8 waiting on condition [0x00000000..0xfba800a0]

"Signal Dispatcher" daemon prio=10 tid=0x00129818 nid=0x7 waiting on condition [0x00000000..0x00000000]

"Finalizer" daemon prio=10 tid=0x000feea8 nid=0x6 in Object.wait() [0xfdd81000..0xfdd816b8]
        at java.lang.Object.wait(Native Method)
        - waiting on <0xf0c005b0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
        - locked <0xf0c005b0> (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=0x000fdc80 nid=0x5 in Object.wait() [0xfde81000..0xfde81838]
        at java.lang.Object.wait(Native Method)
        - waiting on <0xf0c00498> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:429)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:118)
        - locked <0xf0c00498> (a java.lang.ref.Reference$Lock)

"main" prio=10 tid=0x0002daa8 nid=0x1 waiting for monitor entry [0xffbee000..0xffbeecd0]
        at java.awt.Window.getOwnedWindows(Window.java:844)
        - waiting to lock <0xf0c41ec8> (a java.util.Vector)
        at javax.swing.SwingUtilities$SharedOwnerFrame.installListeners(SwingUtilities.java:1697)
        at javax.swing.SwingUtilities$SharedOwnerFrame.addNotify(SwingUtilities.java:1690)
        at java.awt.Dialog.addNotify(Dialog.java:370)
        - locked <0xf0c30560> (a java.awt.Component$AWTTreeLock)
        at java.awt.Dialog.conditionalShow(Dialog.java:441)
        - locked <0xf0c30560> (a java.awt.Component$AWTTreeLock)
        at java.awt.Dialog.show(Dialog.java:499)
        at java.awt.Component.show(Component.java:1287)
        at java.awt.Component.setVisible(Component.java:1242)
        at test01.main(test01.java:10)

"VM Thread" prio=10 tid=0x000fbd60 nid=0x4 runnable

"VM Periodic Task Thread" prio=10 tid=0x0012cb68 nid=0xa waiting on condition


Found one Java-level deadlock:
=============================
"AWT-EventQueue-0":
  waiting to lock monitor 0x000ffbf8 (object 0xf0c30560, a java.awt.Component$AWTTreeLock),
  which is held by "main"
"main":
  waiting to lock monitor 0x000ffe38 (object 0xf0c41ec8, a java.util.Vector),
  which is held by "AWT-EventQueue-0"

Java stack information for the threads listed above:
===================================================
"AWT-EventQueue-0":
        at java.awt.Container.removeNotify(Container.java:2503)
        - waiting to lock <0xf0c30560> (a java.awt.Component$AWTTreeLock)
        at java.awt.Window$1DisposeAction.run(Window.java:604)
        at java.awt.Window.doDispose(Window.java:617)
        at java.awt.Dialog.doDispose(Dialog.java:625)
        at java.awt.Window.dispose(Window.java:574)
        at java.awt.Window.disposeImpl(Window.java:584)
        at java.awt.Window$1DisposeAction.run(Window.java:598)
        - locked <0xf0c41ec8> (a java.util.Vector)
        at java.awt.Window.doDispose(Window.java:617)
        at java.awt.Window.dispose(Window.java:574)
        at javax.swing.SwingUtilities$SharedOwnerFrame.dispose(SwingUtilities.java:1743)
        at javax.swing.SwingUtilities$SharedOwnerFrame.windowClosed(SwingUtilities.java:1722)
        at java.awt.Window.processWindowEvent(Window.java:1173)
        at javax.swing.JDialog.processWindowEvent(JDialog.java:407)
        at java.awt.Window.processEvent(Window.java:1128)
        at java.awt.Component.dispatchEventImpl(Component.java:3922)
        at java.awt.Container.dispatchEventImpl(Container.java:2009)
        at java.awt.Window.dispatchEventImpl(Window.java:1746)
        at java.awt.Component.dispatchEvent(Component.java:3770)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:214)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
"main":
        at java.awt.Window.getOwnedWindows(Window.java:844)
        - waiting to lock <0xf0c41ec8> (a java.util.Vector)
        at javax.swing.SwingUtilities$SharedOwnerFrame.installListeners(SwingUtilities.java:1697)
        at javax.swing.SwingUtilities$SharedOwnerFrame.addNotify(SwingUtilities.java:1690)
        at java.awt.Dialog.addNotify(Dialog.java:370)
        - locked <0xf0c30560> (a java.awt.Component$AWTTreeLock)
        at java.awt.Dialog.conditionalShow(Dialog.java:441)
        - locked <0xf0c30560> (a java.awt.Component$AWTTreeLock)
        at java.awt.Dialog.show(Dialog.java:499)
        at java.awt.Component.show(Component.java:1287)
        at java.awt.Component.setVisible(Component.java:1242)
        at test01.main(test01.java:10)

Found 1 deadlock.



JCK test source location:
==========================
/java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests

Test output:
=============
#Test Results (version 2)
#Wed Oct 08 05:34:24 PDT 2003
#checksum:1b015ff7645951a8
#-----testdescription-----
$file=/scratch/jckauto/work/r002work9087/JCK-runtime-15/tests/api/javax_swing/JDialog/AccessibleJDialog/index.html
$root=/scratch/jckauto/work/r002work9087/JCK-runtime-15/tests
executeArgs=-TestCaseID ALL
executeClass=javasoft.sqe.tests.api.javax.swing.JDialog.AccessibleJDialog.AccessibleComponentTests
id=AccessibleComponent
keywords=positive runtime
selectIf=!platform.isHeadless
source=AccessibleComponentTests.java
title=AccessibleComponent() methods tests

#-----environment-----
command.testExecute=com.sun.jck.lib.ExecJCKTestOtherJVMCmd LD_LIBRARY_PATH=/java/jck/pkgs/jckjni/tiger/beta/b06/solaris-sparcv9/32bit DISPLAY=talkinghead:2 HOME=${user.home}  /scratch/jckauto/work/r002work9087/j2sdk1.5.0/bin/java -client -Xint  -Xms32m -Xmx192m   -Djava.security.policy=/scratch/jckauto/work/r002work9087/JCK-runtime-15/lib/jck.policy -Djava.rmi.activation.port=42006 -Dmultitest.testcaseOrder=reverseSorted -Xfuture -classpath $testSuiteRootDir/classes -Djava.security.policy=$testSuiteRootDir/lib/jck.policy -Djava.rmi.activation.port=42006 $testExecuteClass $testExecuteArgs

#-----testresult-----
description=file:///scratch/jckauto/work/r002work9087/JCK-runtime-15/tests/api/javax_swing/JDialog/AccessibleJDialog/index.html#AccessibleComponent
end=Wed Oct 08 05:34:24 PDT 2003
environment=beta_b06_r002
execStatus=Failed. test cases: 27; passed: 26; failed: 1; first test case failure: AccessibleJDialog0022
javatestOS=SunOS 5.9 (sparc)
javatestVersion=3.1.4
script=com.sun.jck.lib.JCKScript 
sections=script_messages testExecute
start=Wed Oct 08 05:34:13 PDT 2003
test=api/javax_swing/JDialog/AccessibleJDialog/index.html#AccessibleComponent
timeoutSeconds=600
work=/scratch/jckauto/work/r002work9087/jtwork/results/api/javax_swing/JDialog/AccessibleJDialog

#section:script_messages
----------messages:(1/24)----------
Executing test class...

#section:testExecute
----------messages:(1/699)----------
command: com.sun.jck.lib.ExecJCKTestOtherJVMCmd LD_LIBRARY_PATH=/java/jck/pkgs/jckjni/tiger/beta/b06/solaris-sparcv9/32bit DISPLAY=talkinghead:2 HOME= /scratch/jckauto/work/r002work9087/j2sdk1.5.0/bin/java -client -Xint -Xms32m -Xmx192m -Djava.security.policy=/scratch/jckauto/work/r002work9087/JCK-runtime-15/lib/jck.policy -Djava.rmi.activation.port=42006 -Dmultitest.testcaseOrder=reverseSorted -Xfuture -classpath /scratch/jckauto/work/r002work9087/JCK-runtime-15/classes -Djava.security.policy=/scratch/jckauto/work/r002work9087/JCK-runtime-15/lib/jck.policy -Djava.rmi.activation.port=42006 javasoft.sqe.tests.api.javax.swing.JDialog.AccessibleJDialog.AccessibleComponentTests -TestCaseID ALL
----------ref:(37/2271)----------
====== AccessibleJDialog2001 ====== public void requestFocus()
====== AccessibleJDialog0036 ====== public void removeFocusListener(FocusListener listener)
====== AccessibleJDialog0035 ====== public void addFocusListener(FocusListener listener)
====== AccessibleJDialog0034 ====== public boolean isFocusTraversable()
====== AccessibleJDialog0033 ====== public Accessible getAccessibleAt(Point point)
====== AccessibleJDialog0032 ====== public Dimension getSize()
====== AccessibleJDialog0031 ====== public void setSize(Dimension value)
====== AccessibleJDialog0030 ====== public Rectangle getBounds()
====== AccessibleJDialog0029 ====== public void setBounds(Rectangle value)
====== AccessibleJDialog0028 ====== public Point getLocation()
====== AccessibleJDialog0027 ====== public void setLocation(Point value)
====== AccessibleJDialog0026 ====== public Point getLocationOnScreen()
getLocationOnScreen works correctly
getLocationOnScreen works correctly
getLocationOnScreen works correctly
getLocationOnScreen works correctly
getLocationOnScreen works correctly
getLocationOnScreen works correctly
getLocationOnScreen works correctly
getLocationOnScreen works correctly
getLocationOnScreen works correctly
getLocationOnScreen works correctly
====== AccessibleJDialog0025 ====== public boolean contains(Point point)
====== AccessibleJDialog0024 ====== public boolean isShowing()
====== AccessibleJDialog0023 ====== public boolean isVisible()
====== AccessibleJDialog0022 ====== public void setVisible(boolean flag)
====== AccessibleJDialog0021 ====== public boolean isEnabled()
====== AccessibleJDialog0020 ====== public void setEnabled(boolean flag)
====== AccessibleJDialog0019 ====== public FontMetrics getFontMetrics(Font font)
====== AccessibleJDialog0018 ====== public Font getFont()
====== AccessibleJDialog0017 ====== public void setFont(Font value)
====== AccessibleJDialog0016 ====== public Cursor getCursor()
====== AccessibleJDialog0015 ====== public void setCursor(Cursor value)
====== AccessibleJDialog0014 ====== public Color getForeground()
====== AccessibleJDialog0013 ====== public void setForeground(Color color)
====== AccessibleJDialog0012 ====== public Color getBackground()
====== AccessibleJDialog0011 ====== public void setBackground(Color color)
----------log:(29/1206)----------
Warning: Cannot convert st

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta FIXED IN: tiger-beta INTEGRATED IN: tiger-b28 tiger-beta VERIFIED IN: 1.5.0_01
28-09-2004

EVALUATION Name: dmR10075 Date: 10/18/2003 The problems is unrelated to 4936652, it is related to another bug(about user overriding dispose, don't remember its ID) I think the wrong sequence of locks is in DisposeAction.run - it should probably work with copy of the list. It shouldn't dispose window under ownedWindows lock. ###@###.### 2003-10-18 ====================================================================== Name: apR10133 Date: 10/22/2003 The problem is that sharedOwnerFrame is disposed on the EDT (on window closed event when the JDilog is closed) under ownedWindows lock. But the same time on the app thread the next JDialog is created and it gets the ownedWindows to add listeners, but Window.getOwnedWindows does the same lock. Hence we get the deadlock mentioned in description. We should do the tree lock while we dispose the sharedOwnerFrame. ###@###.### ======================================================================
28-09-2004

SUGGESTED FIX Name: apR10133 Date: 10/22/2003 ------- SwingUtilities.java ------- *** /tmp/sccs.6TaiDi Wed Oct 22 16:59:58 2003 --- SwingUtilities.java Wed Oct 22 16:56:25 2003 *************** *** 1709,1725 **** * displayable children left. */ public void windowClosed(WindowEvent e) { ! Window[] windows = getOwnedWindows(); ! for (int ind = 0; ind <windows.length; ind++) { ! Window window = windows[ind]; ! if (window != null) { ! if (window.isDisplayable()) { ! return; } - window.removeWindowListener(this); } } - dispose(); } public void windowOpened(WindowEvent e) { } --- 1709,1727 ---- * displayable children left. */ public void windowClosed(WindowEvent e) { ! synchronized(getTreeLock()) { ! Window[] windows = getOwnedWindows(); ! for (int ind = 0; ind < windows.length; ind++) { ! Window window = windows[ind]; ! if (window != null) { ! if (window.isDisplayable()) { ! return; ! } ! window.removeWindowListener(this); } } + dispose(); } } public void windowOpened(WindowEvent e) { } ====================================================================== ###@###.### 2004-09-27
27-09-2004