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
:
- declaringClass:
RUBY
- methodName:
compute
- fileName:
<script>
- lineNumber:
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 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
:
- declaringClass:
RUBY
- methodName:
compute
- fileName:
<script>
- lineNumber:
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>);
Share
Improve this question
edited Mar 12 at 8:36
Hervé Girod
asked Mar 12 at 8:17
Hervé GirodHervé Girod
5694 silver badges21 bronze badges
2
|
1 Answer
Reset to default 1I 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();
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744764657a4592385.html
__FILE__
do what you want? Why do you need aStackTraceElement
? – user1934428 Commented Mar 27 at 11:11