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

peer objects not visible to GC; classes may be unloaded

    XMLWordPrintable

Details

    • unknown
    • generic

    Description

      This bug showed up in Java Workshop and I don't have a small example.
      Here is the scenario: A thread creates a frame containing a button.
      That thread terminates without destroying the frame. The garbage collector
      runs and doesn't find any references to the frame's class, so it unloads it,
      along with the classes referenced by its event handler. Later, the user
      clicks on the button and the frame's eventHandler method is called.
      The classes referenced by that event handler are then reloaded and
      reinitialized but the prior contents of static fields are lost.

      We have verified that this is happening on win32 by printing a message
      from the class initializer of a class referenced by the event handler.
      The message shows up twice, indicating that the class is indeed being
      unloaded when the first thread exits.

      On Solaris, I looked around in the AWT code and I think I found the
      problem. In src/solaris/sun/awt_MToolkit.c, there is a linked list
      containing references to the peer objects. The list is rooted with
      a static variable awt_winfo. That variable is not scanned by the garbage
      collector nor does there appear to be any interface by which the GC
      could traverse the list to find the peer objects.

      On win32, I scanned through the code but the problem was not so obvious to
      me. Hopefully someone who is more familiar with the code will know
      where to look.

      Attachments

        Issue Links

          Activity

            People

              mbronsonsunw Mike Bronson (Inactive)
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: