Script names in jruby stack traces

I am incorporating scripting into our application. In order to mark
errors for
the user we parse the exception stacktrace and jython provides
information
about which line(s) in which script(s) participate in the call stack.

at test1$py.runtest$1
(/workspaces/runtime-clearingtool.product/Test/regressiontests/test1.py:8)

at test2$py.runtest$1
(/workspaces/runtime-clearingtool.product/Test/regressiontests/test2.py:7)

unfortunately jruby does not provide the same information (tested with
1.1.5
and 1.2)

would it be possible to provide the file and line number information in
the
jruby stacktraces? Or is it possible to get the (current) ruby stack
trace
from the JRubyScriptEngine in some way?

see attachments for more details.

Thanks in advance!

P.S.
please cc me, as I only check the mailing list archives infrequently.

Lothar

Lothar Werzinger wrote:

I am incorporating scripting into our application. In order to mark errors for
the user we parse the exception stacktrace and jython provides information
about which line(s) in which script(s) participate in the call stack.

unfortunately jruby does not provide the same information (tested with 1.1.5
and 1.2)

would it be possible to provide the file and line number information in the
jruby stacktraces? Or is it possible to get the (current) ruby stack trace
from the JRubyScriptEngine in some way?

Yes, it is possible. Jython most likely is showing you all this
information because it’s compiling all that code up-front. In JRuby’s
case, we are usually interpreting code, at least for a while, so there’s
no compiled Java stack to show you.

However I think we’ve started a gradual move toward a full-compiled
option as the way to run reall applications. Startup time suffers
somewhat (may be something we can improve) but ultimately this allows us
to show the actual source lines in the Java backtrace, as well as
perform additional optimizations.

For example, notice the “-e:1” file and line number running -X+C:

~ âž” jruby -rjava -X+C -e “def foo; bar; end; def bar; baz; end; def baz;
java.lang.Thread.dump_stack; end; foo”
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1206)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jruby.javasupport.JavaMethod.invokeWithExceptionHandling(JavaMethod.java:298)
at org.jruby.javasupport.JavaMethod.invoke_static(JavaMethod.java:278)
at
org.jruby.java.invokers.StaticMethodInvoker.call(StaticMethodInvoker.java:38)
at
org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:56)
at
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:253)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:72)
at ruby.dash_e.method__2$RUBY$baz(-e:1)
at ruby.__dash_e__Invokermethod__2$RUBY$bazFixed0.call(dash_e#baz)
at ruby.__dash_e__Invokermethod__2$RUBY$bazFixed0.call(dash_e#baz)
at
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:253)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:72)
at ruby.dash_e.method__1$RUBY$bar(-e:1)
at ruby.__dash_e__Invokermethod__1$RUBY$barFixed0.call(dash_e#bar)
at ruby.__dash_e__Invokermethod__1$RUBY$barFixed0.call(dash_e#bar)
at
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:253)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:72)
at ruby.dash_e.method__0$RUBY$foo(-e:1)
at ruby.__dash_e__Invokermethod__0$RUBY$fooFixed0.call(dash_e#foo)
at ruby.__dash_e__Invokermethod__0$RUBY$fooFixed0.call(dash_e#foo)
at
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:253)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:72)
at ruby.dash_e.file(-e:1)
at ruby.dash_e.load(-e)
at org.jruby.Ruby.runScript(Ruby.java:590)
at org.jruby.Ruby.runNormally(Ruby.java:493)
at org.jruby.Ruby.runFromMain(Ruby.java:367)
at org.jruby.Main.run(Main.java:229)
at org.jruby.Main.run(Main.java:110)
at org.jruby.Main.main(Main.java:94)

And --fast:

~ âž” jruby -rjava --fast -e “def foo; bar; end; def bar; baz; end; def
baz; java.lang.Thread.dump_stack; end; foo”
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1206)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jruby.javasupport.JavaMethod.invokeWithExceptionHandling(JavaMethod.java:298)
at org.jruby.javasupport.JavaMethod.invoke_static(JavaMethod.java:278)
at
org.jruby.java.invokers.StaticMethodInvoker.call(StaticMethodInvoker.java:38)
at
org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:56)
at
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:253)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:72)
at ruby.dash_e.method__2$RUBY$baz(-e:1)
at ruby.__dash_e__Invokermethod__2$RUBY$bazFixed0.call(dash_e#baz)
at ruby.__dash_e__Invokermethod__2$RUBY$bazFixed0.call(dash_e#baz)
at
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:253)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:72)
at ruby.dash_e.method__1$RUBY$bar(-e:1)
at ruby.__dash_e__Invokermethod__1$RUBY$barFixed0.call(dash_e#bar)
at ruby.__dash_e__Invokermethod__1$RUBY$barFixed0.call(dash_e#bar)
at
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:253)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:72)
at ruby.dash_e.method__0$RUBY$foo(-e:1)
at ruby.__dash_e__Invokermethod__0$RUBY$fooFixed0.call(dash_e#foo)
at ruby.__dash_e__Invokermethod__0$RUBY$fooFixed0.call(dash_e#foo)
at
org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:253)
at
org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:72)
at ruby.dash_e.file(-e:1)
at ruby.dash_e.load(-e)
at org.jruby.Ruby.runScript(Ruby.java:590)
at org.jruby.Ruby.runNormally(Ruby.java:493)
at org.jruby.Ruby.runFromMain(Ruby.java:367)
at org.jruby.Main.run(Main.java:229)
at org.jruby.Main.run(Main.java:110)
at org.jruby.Main.main(Main.java:94)


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email