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

EventQueue should prevent usage during shutdown hook

XMLWordPrintable

    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      EventQueue.invokeLater() and EventQueue.invokeAndWait() should throw an exception in case it is invoked from a shutdown thread.

      This exception should be documented and become part of the new spec (so yes, we're modifying the API specification) but I don't think that this is breaking backwards compatibility because the current behavior is that instead of throwing an exception a deadlock will occur.

      JUSTIFICATION :
      If an application registers a shutdown hook, it is able to know not to rely on the EventQueue (i.e. don't invoke JFrame.dispose()) but 3rd party libraries have absolutely no way of finding out whether they're running inside a shutdown hook or not.

      The only way to prevent deadlocks from occuring is to throw an exception which signals that we're inside a shutdown hook (or the EventQueue is otherwise unavailable).

      This will allow libraries to catch the exception and continue shutting down without interacting with AWT components. For example, temporarily files can be removed, etc... without closing windows.

            art Artem Ananiev (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: