Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6855230

Call to dispose a JFRAME in a ShutdownHook block on Windows not on Linux

    XMLWordPrintable

Details

    • Cause Known
    • x86
    • windows_xp

    Description

      FULL PRODUCT VERSION :
      Linux and Windows:
      java version "1.6.0_13"
      Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
      Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      WinXP SP3
      Linux Debian testing - libc6 2.9-4 - kernel 2.6.26-1-686 - xorg 7.3

      A DESCRIPTION OF THE PROBLEM :
      I have a program performing several tasks when the main frame is disposed. In addition I would like to manage correctly all events such as SIGINT, user end session (WM_QUERYENDSESSION), but it seems that we can't call the dispose method on a JFrame in a shutdown hook (it runs perfectly on Linux but blocks on Windows).


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
       to see easily the problem, run the code on a command line and perform a Ctrl+C (on Windows, the program never return)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Either an exception (if it's an illegal operation), or windows behave like linux.
      ACTUAL -
      the program blocks under windows

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      no error message

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JFrame;
        import javax.swing.SwingUtilities;
        public static void main(String[] args) {
          final JFrame frame = new JFrame("Title");
          SwingUtilities.invokeLater(new Runnable() {
            @Override public void run() {frame.setVisible(true);}
          });
          Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override public void run() {frame.dispose();}
          }
          ));
        }

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

      Attachments

        Activity

          People

            art Artem Ananiev (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Imported:
              Indexed: