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

Over riding dialog show will cause a hang on Solaris.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.0.2
    • client-libs
    • None
    • sparc
    • solaris_2.4

      Include is a description of a bug from Corel. They are only
      testing HotJava on Solaris. I was able to reproduce it using
      the 1.0.2 appletviewer. It works in netscape. I suspect the
      problem is a 1.0.2 regression. Test case included below.


      Overridding dialog.show() will make dialogs end up
      in a deadlock on Unix's HotJava.

      While JavaSoft's bug report on the modal dialog
      suggests to override dialog.show() to get around a
      win32 implementation bug, by doing so will cause
      the same dialog to deadlock in HotJava on Unix.

      I appended to this message a sample applet that
      demonstrates this bug. If you run it in HotJava, it
      will hang in both situations presented.

      On our side, we will try to get rid of all the
      show() overrides.

      The bad thing is that we never suspected that this
      would have been the problem. How can you think
      that removing the following code would have fixed
      the problem?:

      public void show()
      {
          super.show();
      }

      But this code was the killer!

      When you have an idea of when this will be fixed,
      let me know. Thanks.

      Claude


      /////////////////////////////////////////////////
      /**
      * Demonstrates the show() synchronize bug.
      *
      * Try this test under any browser on the Unix
      platform.
      * You have a sure hang:
      *
      * HotJava: both dialogs will hang.
      * Others: Will hang if the override of
      dialog.show() is synchronized
      * (as documented in the javasoft's bug
      reports)
      *
      */

      import java.awt.*;

      public class DialogShowBug extends
      java.applet.Applet
      {

          public DialogShowBug()
          {
          }

          public void init()
          {
              new MyFrame();
          }
      }


      class MyFrame extends Frame
      {

          public MyFrame()
          {
           resize(400, 200);
              MenuBar menuBar = new MenuBar();
              Menu menu = new Menu("test");
              menu.add(new MenuItem("Invoke NON
      synchronized Show"));
              menu.add(new MenuItem("Invoke synchronized
      Show"));
              menuBar.add(menu);
              setMenuBar(menuBar);
           show();
          }

          public boolean action(Event event, Object
      eventParam)
          {
              String strLabel = (String)eventParam;
              if(strLabel.equals("Invoke NON synchronized
      Show"))
              {
                  Dialog dlg = new NonSyncDlg(this);
                  dlg.show();
                  return true;
              }
              else if(strLabel.equals("Invoke synchronized
      Show"))
              {
                  Dialog dlg = new SyncDlg(this);
                  dlg.show();
                  return true;
              }
              return super.action(event, eventParam);
          }
      }

      class Test extends Dialog
      {
          Button button;

          public Test(Frame parent, String title)
          {
      super(parent, title, true);
      addNotify();
      reshape(parent.bounds().x +10,
      parent.bounds().y, 300, 100);
              setLayout(null);
              button = new Button("OK");
              button.reshape(insets().left +
      10,insets().top + 50, 70, 28);
              add(button);
          }


          public boolean action(Event evt, Object what)
          {
           if(evt.arg.equals("OK"))
           {
           dispose();
           return true;
           }
           return super.action(evt, what);
          }
      }

      class NonSyncDlg extends Test
      {
          public NonSyncDlg(Frame parent)
          {
      super(parent, "Invoke NON synchronized
      Show");
          }

          public void show()
          {
              super.show();
          }
      }

      class SyncDlg extends Test
      {
          public SyncDlg(Frame parent)
          {
      super(parent, "Invoke synchronized Show");
          }

          public synchronized void show()
          {
              super.show();
          }
      }


            gsaab Georges Saab
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: