ActiveState Community

JavaScript-in-Java debugger

Posted by mickish on 2007-09-03 10:50
OS: All / Any

Please help me understand if I can leverage the Komodo debugger as a platform for some tools I am building.

My goal is a main application with an embedded JavaScript interpreter that supports JavaScript debugging. Users of my application should be able to type in moderately complicated algorithms expressed in JavaScript, which I evaluate for side-effects and return values. You could consider these user-defined algorithms as 'customizations' of the main Java application.

I understand Komodo out-sources its JavaScript interpreter to Firefox. So I am prepared to launch my own JavaScript interpreter myself.

In fact, I am inclined to write a Komodo extension that launches a Java process, which in turn spawns a JavaScript interpreter (Mozilla Rhino). This is desirable because the JavaScript interpreter needs to call Java classes and methods that have already been written anyway. Calling back into Java from JavaScript is straightforward via JavaScript's LiveConnect feature.

In this scenario, Komodo would be the main application, with my tools as an extension, interacting with the Komodo debugger.

My main question is, how would I connect the JavaScript interpreter to Komodo's debugging interface? In particular, how would I halt execution at the beginning of a JavaScript eval(), and step through execution?

More generally, what is the programming interface that enables Komodo extensions to halt their own execution and activate the debugger?

Thanks for your advice,

--Andrew Mickish

shanec | Mon, 2007-09-03 11:36

Hi Andrew, your first stumbling block would be support for the DBGP protocol that enables debugging. The hybrid JS in JVM model you're talking about would require a Java DBGP implementation that knows how to handle the debugging of languages implemented on the JVM. We currently have nothing like that, but there are a couple Eclipse based groups that are working on DBGP support. One is the DLTK group, and there was someone else working on a Java DBGP implementation as well (cannot remember off the top of my head). So unfortunately, there is no out-of-box capability for this right now.

Regards,
Shane