JDK-6276419 : REGRESSION: stacked modal dialogs freeze the System
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0,5.0u3
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2005-05-26
  • Updated: 2011-02-16
  • Resolved: 2006-01-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.0u7Resolved
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]

EXTRA RELEVANT SYSTEM CONFIGURATION :
full updated

A DESCRIPTION OF THE PROBLEM :
Our comlex application stacked modal dialogs on top of each other. In some cases the system hangs with the latest jre.
Last system without the effect was 1.5.0_02

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
* Start the test case
* press "go on"
* press "go on"
* press "go on"
* press "OK"

Now the application hangs.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
"Dialog2" is on top an usable
ACTUAL -
"Frame1" is focused and no input is possible

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.event.*;
import javax.swing.*;

class ModalTest extends JFrame {
  
  public static void main(String[] args) {
    try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Throwable ex) { }
    new ModalTest().setVisible(true);
  }

  ModalTest() {
    super("Frame1");
    this.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });
    JButton btn1 = new JButton();
    btn1.setText("go on");
    btn1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        Dialog1 dlg = new Dialog1();
        dlg.initFields();
        dlg.setVisible(true);
      }
    });
    this.getContentPane().add(btn1);
    pack();
  }

  class Dialog1 extends JDialog {

    private JDialog dlg2;
    
    Dialog1() {
      super(ModalTest.this, "Dialog1", true);
      JButton btn1 = new JButton();
      btn1.setText("go on");
      btn1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
          dlg2.setVisible(true);
        }
      });
      getContentPane().add(btn1);
      pack();
      this.setLocation(50, 20);
    }

    void initFields() {
      dlg2 = new Dialog2();
    }
  }

  class Dialog2 extends JDialog {

    Dialog2() {
      super(ModalTest.this, "Dialog2", true);
      JButton btn1 = new JButton();
      btn1.setText("go on");
      btn1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          btn1_actionPerformed();
        }
      });
      getContentPane().add(btn1);
      pack();
      this.setLocation(80, 40);
    }

    private void btn1_actionPerformed() {
      JOptionPane.showMessageDialog(ModalTest.this, "last message before system hangs", "JOptionPane", JOptionPane.WARNING_MESSAGE);
    }
  }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
use jre1.5.0_02 or create dlg2 later

Release Regression From : 5.0u2
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.
###@###.### 2005-05-26 09:14:30 GMT

Comments
SUGGESTED FIX Explicitly set disabled level of the dialog being shown to 0: *** /tmp/geta23174.s23177 Wed Jun 1 14:18:14 2005 --- awt_Dialog.cpp Wed Jun 1 14:18:13 2005 *************** *** 166,171 **** --- 166,174 ---- DASSERT(AwtModalityNestCounter >= 0 && AwtModalityNestCounter <= 1000); // sanity check AwtModalityNestCounter++; #endif + if (hWndDlg != NULL) { + SetDisabledLevel(hWndDlg, 0); + } ::EnumThreadWindows(AwtToolkit::MainThread(), (WNDENUMPROC)DisableTopLevelsCallback,(LPARAM)hWndDlg) ; } ###@###.### 2005-06-01 10:22:44 GMT
01-06-2005

EVALUATION Seem to be reproducible with update 03 only. There is no hang with improved modality. ###@###.### 2005-05-30 08:50:55 GMT The bug is caused by the fix for 5092094 (implementation of modal exclusion feature in 5.0u3). Before that fix all the modal dialogs were explicitly enabled before they are shown by removing blocked level property, but after the fix that property wasn't removed to save modal exclusion state. As the result, in the test presented the second modal dialog is blocked by the first one and after hiding JOptionPane all the windows are left disabled. ###@###.### 2005-06-01 10:22:44 GMT
30-05-2005