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

Incorrect AWT code in sun.applet.AppletPanel

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 6
    • 6
    • deploy
    • b85
    • generic
    • generic

    Description

      The sun.applet.AppletPanel class is performing illegal AWT operations internally upon applet termination. The general rule is that once a component hierarchy is visible, all operations on the components should be performed on the Event Dispatch Thread using EventQueue.invokeAndWait() / invokeLater() for correctness. The AppletPanel is performing remove() calls on its own thread rather than handing this work off to the EDT to be done there. This causes deadlocks with applets which attempt to be smart about doing all of their work on the EDT.

      The attached jstack output shows a deadlock that occurs with the open-source JOGL library (http://jogl.dev.java.net/) in conjunction with applets. AppletPanel calls remove() which ends up calling GLCanvas.removeNotify(). The implementation of this method detects that it is not on the EDT and attempts to perform its OpenGL-related work on the EDT to mitigate driver-level issues. Because the current thread holds the AWT tree lock (by virtue of having called remove() directly rather than performing the remove() call on the EDT) the fact that this thread blocks waiting for the EDT to execute a Runnable causes a deadlock as soon as the EDT attempts to acquire the tree lock.

      This bug should be fixed by changing the AppletPanel to perform its remove() call using EventQueue.invokeAndWait(). In the interim we have worked around this bug in the JOGL library by causing it to detect the deadlock situation and perform the associated OpenGL work on the current thread, which is not the best behavior but is better than deadlocking the JVM.

      Attachments

        Activity

          People

            ccheung Calvin Cheung
            kbr Kenneth Russell (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: