Hi.
K. W. Landry:
> I've worked on this for a long time and I'm getting no where. Other than
> the source for Squiggle, there are no examples for getting this done that I
> can find. It's possible I'm going about it all wrong but, I can't find any
> other references, so......
>
> JS.jar is in the build path, I've visually checked it and I get the class
> references in the early lines of the code, as I step through in the eclipse
> debug view,
>
> My code to invoke the mozilla jscript debugger from my batik svg viewer
> fails like so:
>
> java.lang.InstantiationException: org.mozilla.javascript.tools.debugger.Main
> at java.lang.Class.newInstance0(Unknown Source)
> at java.lang.Class.newInstance(Unknown Source)
> at com.bluepearlsystems.Client.BluePearlViewer.showDebugger(
> BluePearlViewer.java:255)
> at com.bluepearlsystems.Client.BluePearlViewer.setSVGCanvas(
> BluePearlViewer.java:352)
> at com.bluepearlsystems.Client.BluePearlViewer.main(BluePearlViewer.java
> :179)
>
> 255 is marked below, it is o = debuggerClass.newInstance();
>
> on this code:
>
> public static void showDebugger() {
> jDebugger();
> if (debuggerClass == null) return;
> if (debuggerFrame == null) {
> Constructor dbgcon = null;
> Constructor[] ca = null;
> try {
> ca = debuggerClass.getConstructors();
> int l = ca.length;
> dbgcon = debuggerClass.getConstructor(new Class [] {
> String.class });
> } catch (SecurityException e1) {
> log.debug("GetConstructor Security Exception:\n "+e1);
> e1.printStackTrace();
> }
> catch (NoSuchMethodException e1) {
> log.debug("GetConstructor No Such Method Exception:\n "+e1);
> e1.printStackTrace();
> }
>
> Object o = null;
> try {
> #255 o = debuggerClass.newInstance();
> } catch (InstantiationException e2) {
> e2.printStackTrace();
> } catch (IllegalAccessException e2) {
> e2.printStackTrace();
> }
>
> debuggerFrame = (JFrame)o;
The org.mozilla.javascript.tools.debugger.Main class only has a
constructor that takes a String argument, so calling
debuggerClass.newInstance() will fail because there’s no constructor
with no arguments. You should use the constructor stored in dbgcon to
instantiate Main.
Note that the only reason Squiggle’s JSVGViewerFrame uses reflection to
invoke the debugger is that Rhino is optional, so the code needs to be
able to compile even without Rhino present. If in your application you
will always have Rhino present, you should just instantiate the debugger
normally, like:
import org.mozilla.javascript.tools.debugger.Main;
…
Main debuggerMain = new Main("My debugger");
> JS.jar is copied to the same directory as Squiggle.
> Squiggle fails after it has started and I click on "Tools", then Script
> Debugger" with the following (copied from the dos box):
This is a separate issue, a bug in Rhino that is causing the debugger
not to be able to run with the policy files that Batik has in place
(see https://bugzilla.mozilla.org/show_bug.cgi?id=367627). Hopefully
the patch will go into Rhino soon.
--
Cameron McCormack, http://mcc.id.au/
xmpp:[EMAIL PROTECTED] ▪ ICQ 26955922 ▪ MSN [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]