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

JDialog.setVisible fails to notify waiting thread

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1
    • Resolution: Fixed
    • Affects Version/s: 1.1.4, 1.1.5
    • Fix Version/s: 1.1.5
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.1.5
    • CPU:
      generic, unknown
    • OS:
      solaris_2.5.1, windows_nt
    • Verification:
      Not verified

      Description



      From: Ray Tomlinson <###@###.###>
      To: ###@###.###
      Cc: ###@###.###
      Subject: JDialog.setVisible fails to notify waiting thread
      Date: Fri, 14 Nov 1997 12:02:13 -0500

      The setVisible method of JDialog contains a race: super.setVisible is done
      after notifyAll with the result that a thread waiting in blockingShow may
      be activated, find that the dialog is still visible, and continue waiting.
      After this, the thread setting visibility false continues, the dialog
      becomes invisible and the blockingShow thread stays blocked -- forever.

      Below is the relevant bytecode:

      Method void setVisible(boolean)
         0 iload_1
         1 ifne 27
         4 aload_0
         5 invokevirtual #75 <Method boolean isVisible()>
         8 ifeq 27
        11 aload_0
        12 astore_2
        13 aload_2
        14 monitorenter
        15 aload_0
        16 invokevirtual #76 <Method void notifyAll()>
        19 aload_2
        20 monitorexit
        21 goto 27
        24 aload_2
        25 monitorexit
        26 athrow
        27 aload_0
        28 iload_1
        29 invokespecial #86 <Method void setVisible(boolean)>
        32 return

      The corresponding source (which Sun has failed to provide), but deduced
      from the bytecode is:

      public void setVisible(boolean newVisible)
      {
        if (!newVisible && isVisible()) {
          synchronized(this) {
            notifyAll();
          }
        }
        super.setVisible(newVisible);
      }

      The code should probably be:

      public void setVisible(boolean newVisible)
      {
        boolean doNotify = (!newVisible && isVisible());
        super.setVisible(newVisible);
        if (doNotify) {
          synchronized(this) {
            notifyAll();
          }
        }
      }

      Ray Tomlinson


      From: Scott Violet <sky@southampton>
      To: ###@###.###
      CC: swing-feedback@taller
      Subject: Re: JDialog.setVisible fails to notify waiting thread
      Date: Fri, 14 Nov 1997 11:09:09 -0800

      Hi,
         Thanks for the excellent diagnosis of the bug! You are correct,
      super.setVisible() is incorrectly being messaged after notifyAll() is
      messaged. We will change this for a future release.
      Thanks again,

      -Scott Violet (###@###.###)

        Attachments

          Activity

            People

            Assignee:
            sswingtrsunw Swingtraq Swingtraq (Inactive)
            Reporter:
            sswingtrsunw Swingtraq Swingtraq (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: