Hi Luke,
I would like to suggest an Echidna patch (it's enclosed as a diff against
recent CVS).
This patch actually combines two unrelated changes:
1. It solves a bug in ProcessGarbageCollector.wakeUp(). I may be wrong here,
but I think it should call notifyAll() on _rootGroup rather than on the
ProcessGarbageCollector itself. Without the patch, when I called System.exit
in an Echidna process, other threads that waitFor() that process took a few
seconds before they woke up. With the patch applied, this happened
instantly.
2. It introduces a new method void setAllowSystemExit(boolean flag) in
ProcessManager. It is a flag that tells whether System.exit() will kill the
current Echidna process (flag==false) or actually exit the whole VM
(flag==true). The advantage is that you can specify an exit code for the
whole program. The old method via ERRORCODE_BYPASS_SECURITY didn't allow
this. (I actually removed that constant and changed ProcessManagerFrame to
use the new method.)
The reason why I am messing with Echidna is that I am currently developing a
patch for the Jakarta Ant tool to incorporate Echidna. Ant build scripts
often fork new VMs because some Java code needs to be executed different
classpath. This is of course rather inefficient. Using custom class loaders
and a little bit of "magic code" for System.out and System.exit, it should
be possible to execute that code in the same VM Ant itself runs in. Luckily,
Echidna provides all this.
I was already able to Echidna-ize a few forked calls in my Ant scripts.
There are still bugs to rule out though...
Provided the Ant patch makes its way into the Ant distribution, it will be
good if it can work with an off-the-shelf Echidna. Returning a meaningful
exit code is essential for Ant, so it will be good if Echidna is changed as
I suggested (or in a similar way).
I am very interested in your feedback.
Best,
-Stefan
|