Hi there,
I have some confusing behaviour where Rhino isn't producing line
numbers in errors when a type error is generated (e.g. trying to call
a method on an object that doesn't exist).
When running a simple standalong helloworld app that runs a script I
see the line numbers in the errors in both interpreted and compiled
mode. And in interpreted mode I also see the JS function names in
stack traces. e.g. the error might be like:
TypeError: Cannot find function xyz in object MyObj. (script#21)
and the relevant part of the stack:
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis
(ScriptRuntime.java:2214)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:
3143)
at script.printJobHook(script:21)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:
2487)
at org.mozilla.javascript.InterpretedFunction.call
(InterpretedFunction.java:164)
at org.mozilla.javascript.ContextFactory.doTopCall
(ContextFactory.java:398)
When running in my app server, I don't get any line numbers if I run
in interpretted mode I don't get any line numbers, and see the
following error and stack:
TypeError: Cannot find function xyz in object MyObj.
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis
(ScriptRuntime.java:2214)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:
3143)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:
2487)
at org.mozilla.javascript.InterpretedFunction.call
(InterpretedFunction.java:164)
at org.mozilla.javascript.ContextFactory.doTopCall
(ContextFactory.java:398)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:
3065)
So you can see that it's calling the interpretted function, but don't
see "script.printJobHook(script:21)" in the stack nor the
"(script#21)" at the end of the error message. If I run in
compiled mode ... it get the line numbers. :(
When running in the app server we're running in a much more
complicated environment (in a jetty web request, Spring, etc, etc).
But for the life of me I can't isolate the difference between the two
environments.
I was hoping someone with knowledge of the Rhino internals would know
when we'd lose the line numbers and stack info in interpretted mode.
Any insight would be appreciated! :)
At this stage I'd prefer to run in script mode, because our scripts
are very short and the compile step isn't worth it. And it's nice to
get the proper functions in the stack trace.
Regards,
Matt
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino