gecko-dev/java
edburns%acm.org d9cd53fece The problem was in the way the
NativeEventThread's run() method's infinite loop was implemented.  The
  loop looks like this:

    while (null != this.browserControlCanvas) {
        synchronized (this.browserControlCanvas.getTreeLock()) {
            nativeProcessEvents(nativeWebShell);

            if (null != listenersToAdd && !listenersToAdd.isEmpty()) {
                tempEnum = listenersToAdd.elements();
                while (tempEnum.hasMoreElements()) {
                    nativeAddListener(nativeWebShell,
                                          (WebclientEventListener)
                                      tempEnum.nextElement());
                }
                listenersToAdd.clear();
            }
        }
    }

  The problem I was observing was that
  nativeProcessEvents(nativeWebShell) would crash due to the fact that
  the nativeWebShell, which is actually an WebShellInitContext instance,
  had been de-allocated.  This de-allocation happens as a result of the
  WindowControlImpl.delete() method, which looks like this:

public void delete()
{
    Assert.assert(null != eventThread, "eventThread shouldn't be null at delete time");
    eventThread.delete();
    eventThread = null;
    nativeDestroyInitContext(nativeWebShell);
    nativeWebShell = -1;
}

  nativeDestroyInitContext de-allocates the WebShellInitContextInstance.
  You can see that the first thing done is to delete the eventThread().
  NativeEventThread.delete() looks like this:

public void delete()
{
    // setting this to null causes the run thread to exit
    synchronized(this.browserControlCanvas.getTreeLock()) {
        browserControlCanvas = null;
    }
...
}

  If you compare NativeEventThread.delete() with the infinite loop in
  NativeEventThread.run(), you'll see that the fact that they both
  synchronize on the same object doesn't protect us from the following
  case:

    NativeEventThread: The infinite loop checks to see if the
    browserControlCanvas is null, then does synchronize on
    browserControlCanvas.getTreeLock(), then calls processNativeEvents().

meanwhile

    WindowControlImpl thread: delete() calls NativeEventThread.delete(),
    which does synchronize on browserControlCanvas.getTreeLock().
    During NativeEventThread.delete(), synchronized section,
    browserControlCanvas is set to null.

    NativeEventThread: because the check for null browserControlCanvas
    occurrs outside of the synchronized block, it's not recheked, and
    thus, the event loop continues to process when it shouldn't.

  The fix is to change the event loop to look like this:

    while (true) {
        synchronized (this.browserControlCanvas.getTreeLock()) {
            // this has to be inside the synchronized block!
            if (null == this.browserControlCanvas) {
                return;
            }
            nativeProcessEvents(nativeWebShell);

            if (null != listenersToAdd && !listenersToAdd.isEmpty()) {
                tempEnum = listenersToAdd.elements();
                while (tempEnum.hasMoreElements()) {
                    nativeAddListener(nativeWebShell,
                                          (WebclientEventListener)
                                      tempEnum.nextElement());
                }
                listenersToAdd.clear();
            }
        }
    }
2000-04-03 04:32:27 +00:00
..
config updated license boilerplate to xPL 1.1, a=chofmann@netscape.com,r=endico@mozilla.org 1999-11-06 02:47:15 +00:00
dom changed == to != 2000-04-01 01:29:59 +00:00
plugins keeping track with Java DOM changes 2000-03-31 01:22:00 +00:00
util Bug #28281, r=leaf, a=leaf, 2000-03-09 01:14:22 +00:00
webclient The problem was in the way the 2000-04-03 04:32:27 +00:00
xpcom updated license boilerplate to xPL 1.1, a=chofmann@netscape.com,r=endico@mozilla.org 1999-11-06 02:47:15 +00:00
Makefile.in Bug #28281, r=leaf, a=leaf, 2000-03-09 01:14:22 +00:00
Makefile.win updated license boilerplate to xPL 1.1, a=chofmann@netscape.com,r=endico@mozilla.org 1999-11-06 02:47:15 +00:00
README THIS FILE IS NOT IN THE BUILD! 1999-08-13 23:10:43 +00:00
changelo Made changes to allow building on jdk1.1.7 or jdk1.2. Basically, accounted 1999-07-30 22:00:20 +00:00
makefiles Bug #28281, r=leaf, a=leaf, 2000-03-09 01:14:22 +00:00

README

Here lies the code that comprises the java enhancers to mozilla.

Authors: see the README files for each individual subdirectory

Requirements:

* JDK1.1.7 or greater (may work with lower versions, haven't checked).

* M8 or post M8 mozilla tree

* Perl 5 perl.exe must be in your path

How To Build:

* make it so the directory in which this file resides is a child of your
  top level mozilla directory

* Copy the files .\config\buildpkg.bat and
  .\config\outofdate.pl to mozilla\config.  These file were
  modified after M8 and the modifications are required to build java.

* make sure the environment var JDKHOME is set to your jdk installation
  directory, ie SET JDKHOME=C:\jdk1.1.8

* type "nmake /f makefile.win all" and hope for the best

* this should compile the clasess into %MOZ_SRC%\dist\classes

Problems:

* clobber_all doesn't remove the .class files from dist\classes.  You
  have to do this manually.

* post to netscape.public.mozilla.java newsgroup

General notes:

* Please update the ChangeLog (changelo) files in the subdirectories when
  you make changes.