Hi,
I’m attempting to write a visual Ruby debugger in a Java applet. As part
of this process, I’m installing my own event handler. I’ve been poking
around jruby-debug and the main interpreter loop in JRuby but can’t seem
to discover a way to abort execution (i.e., break out of the event
handler and execute no further instructions).
I thought that throwing a ThreadKill exception would suffice. From
within the event handler:
context.getThread().kill();
The problem is, this seems to get caught somewhere inside of JRuby.
Elsewhere in my code, I have:
// Install event hook and transfer control to it
jRubyRuntime.addEventHook(this);
try
{
jRubyContainer.runScriptlet(script); // eventHandler() will
now handle the message queue
}
catch (ThreadKill e)
{
System.out.printf(“VM #%d aborted trace\n”, id);
}
The exception is never caught. A stack trace is printed. Is there a safe
way of doing this?
It would also be nice to be able to halt a script externally (to
implement timeouts, for example). I’m aware of RubyThread.stop() but it
seems like this is intended to halt RubyThreads and is for internal use,
not for an external application embedding JRuby.
Thank you!
– Bart
P.S. Re: my other post concerning AccessControl violations within an
applet, I’ve found a temporary workaround and have filed a bug report as
requested.