2009/12/9 Attila Szegedi <[email protected]>:
> On 2009.11.30., at 18:21, Charles Oliver Nutter wrote:
>
>> Yes, blasted stack traces...they are a pain to cope with for sure.
>> JRuby and Jython are probably the only two widely-used JVM languages
>> that present *nice* stack traces
>
> Rhino, in interpreted mode, will inject script stack elements into the Java 
> stack elements, so above every org.mozilla.javascript.Interpreter.interpret() 
> element, you'll have all the JS frames the interpreter created, with an 
> appropriate syntax (function name + source code name + line number; obviously 
> the class name doesn't apply...).

Not to forget the getScriptStackTrace() method in RhinoException. This
works in both compiled and interpreted mode, and returns a (synthetic)
stack trace including only the script sources. In Helma NG the
developer is usually presented two dedicated stack traces as shown
below. I think this is much preferable to messing with the actual
stack trace which diminishes its usefulness for the language
implementor.

ReferenceError: "foo" is not defined.
Script Stack
        at actions.js:67
        at helma/webapp.js:97
        at helma/webapp.js:47
        at helma/middleware/notfound.js:10
        at helma/middleware/error.js:13
        at helma/middleware/responselog.js:26
        at helma/middleware/etag.js:15
        at helma/middleware/gzip.js:15
        at helma/jsgi.js:31
Java Stack
org.mozilla.javascript.EcmaError: ReferenceError: "foo" is not
defined. (actions.js#67)
        at 
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3753)
        at 
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3731)
        at 
org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3816)
        at 
org.mozilla.javascript.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1826)
        at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1765)
        at org.mozilla.javascript.gen.actions_js_29._c_logging_7(actions.js:67)
        at org.mozilla.javascript.gen.actions_js_29.call(actions.js)
        ...

Hannes

> Here's a stack trace from an edit/run debug cycle iteration from my actual 
> work from last week; with client names stripped out. You can see we actually 
> have two interpreter invocations - Array.forEach() is implementing in Java 
> and is thus traversing Java code, and the JS stack frames are correctly 
> injected in their places. The script elements are "at script...":
>
> org.mozilla.javascript.EcmaError: TypeError: Cannot find function getAlertId 
> in object [object Object]. 
> (http://localhost:8080/applications/*************/3.0/main.js#19)
>        at 
> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3753)
>        at 
> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3731)
>        at 
> org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3759)
>        at 
> org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3778)
>        at 
> org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3842)
>        at 
> org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2343)
>        at 
> org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2310)
>        at 
> org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1515)
>        at 
> script(http://localhost:8080/applications/*************/3.0/main.js:19)
>        at 
> script(jar:http://localhost:8080/platform/7.2.0/tools/tools.jar!/com/*******7/workflow/alert/callbacks.js:81)
>        at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:845)
>        at 
> org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
>        at 
> org.mozilla.javascript.NativeArray.iterativeMethod(NativeArray.java:1559)
>        at org.mozilla.javascript.NativeArray.execIdCall(NativeArray.java:340)
>        at 
> org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:129)
>        at 
> org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1702)
>        at 
> script(jar:http://localhost:8080/platform/7.2.0/tools/tools.jar!/com/*******7/workflow/alert/callbacks.js:80)
>        at 
> script(jar:http://localhost:8080/platform/7.2.0/tools/tools.jar!/com/*******7/workflow/alert/alert.js:84)
>        at 
> script(http://localhost:8080/applications/*************/3.0/main.js:27)
>        at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:845)
>        at 
> org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
>        at 
> org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
>        at 
> org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3157)
>        at 
> org.mozilla.javascript.Context.callFunctionWithContinuations(Context.java:1204)
>        at 
> org.mozilla.javascript.Context.executeScriptWithContinuations(Context.java:1171)
>        ...
>
> Attila.
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "JVM Languages" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/jvm-languages?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en.


Reply via email to