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

[macosx] JFileChooser showSaveDialog hangs jvm on the second time you display it

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.8.0_51"
      Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
      Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS X Yosemite 10.10.4

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      MacBook Pro (Retina, 15-inch, Mid 2015)
      2.5 GHz Intel Core i7
      16 GB 1600 MHz DDR3
      AMD Radeon R9 M370X 2048 MB

      A DESCRIPTION OF THE PROBLEM :
      If you display a save file dialog using JFileChooser, it works correctly the first time. However, if you try to do so a second time, the jvm hangs on trying to display the dialog.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Display a save dialog with JFileChooser using the showSaveDialog method.

      2. Click either save or cancel as it does not affect the outcome.

      3. Create a new JFileChooser and try to display it again using the showSaveDialog method.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The JFileChooser save dialog should appear.
      ACTUAL -
      The JVM hangs.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      The JVM only hangs. It does not crash. No crash logs or exceptions are produced. I do see the following message on the Mac OS X console each time the jvm hangs in these instances ...

      WindowServer[159]: _CGXRemoveWindowFromWindowMovementGroup: Window not in group



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Main
      {
          public static void main(String[] args)
          {
              doTest(); //will work fine
              doTest(); //jvm will hang here
          }
          
          public static void doTest()
          {
              try
              {
                  JFileChooser fc = new JFileChooser();
                  int r = fc.showSaveDialog(null);
                  if (r == JFileChooser.APPROVE_OPTION)
                  {
                      System.out.println("Chose Save");
                  }
                  else
                  {
                      System.out.println("Chose Cancel");
                  }
              }
              catch (Throwable t)
              {
                  System.out.println(t);
              }
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No workaround has been found.

            aivanov Alexey Ivanov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: