I am using JRuby, but I am often calling scripts from other scripts, which means that when I have StackTraces from the Java caller, not all the StackTraceElement
s are coming from the initial calling class.
For example, if I have the following code in Ruby:
public
def compute()
retur 10
end
I have the following StackTraceElement
:
RUBY
compute
<script>
3
I would like to get somewhere the name of my script, is it possible to get it in JRuby?
I am creating the script by:
RubyRuntimeAdapter adapter = JavaEmbedUtils.newRuntimeAdapter();
IRubyObject io = adapter.eval(runtime, <scriptContent>);
I understood how to do it. Rather than:
IRubyObject io = adapter.eval(runtime, <scriptContent>);
I have to do:
JavaEmbedUtils.EvalUnit evalUnit = adapter.parse(runtime, <scriptContent>, <file name>, 1);
IRubyObject io = evalUnit.run();