Forum: JRuby script names in jruby stack traces

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
668c6c799ec3488df117fef4deccccd2?d=identicon&s=25 Lothar Werzinger (Guest)
on 2009-03-18 23:44
(Received via mailing list)
Attachment: jruby-stack.txt (2 KB)
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
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-03-19 07:19
(Received via mailing list)
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
This topic is locked and can not be replied to.