-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
After #8723 was fixed, I came across a new problem with it, but this time:
- it works fine on jruby cli built using rbenv
- The problem only exists in JRubyEngine interpreted code
I have reused https://github.com/jimtng/jruby10-bundle to demonstrate the problem, but in summary:
code:
package com.example;
import javax.script.ScriptEngine;
public class App {
public static void main(String[] args) throws Exception {
javax.script.ScriptEngineFactory factory = new org.jruby.embed.jsr223.JRubyEngineFactory();
ScriptEngine engine = factory.getScriptEngine();
engine.eval("""
puts "JRuby Version: #{JRUBY_VERSION}"
puts "JRuby Revision: #{JRUBY_REVISION}"
[1, 2].each do
puts it
end
""");
}
}Output:
$ java -cp target/jruby10-bundler-1.0-SNAPSHOT-jar-with-dependencies.jar com.example.App
JRuby Version: 10.0.0.0-SNAPSHOT
JRuby Revision: 0b9a1dc03c00403b45c862a22baf027212d7a2d0
Exception in thread "main" javax.script.ScriptException: Error during evaluation of Ruby in <script> at line 5: (NameError) undefined local variable or method 'it' for main
at org.jruby.embed.jsr223.JRubyEngine.wrapRaiseException(JRubyEngine.java:282)
at org.jruby.embed.jsr223.JRubyEngine.doEval(JRubyEngine.java:102)
at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:118)
at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:147)
at com.example.App.main(App.java:16)
Caused by: org.jruby.exceptions.NameError: (NameError) undefined local variable or method 'it' for main
at RUBY.<main>(<script>:5)
at org.jruby.RubyArray.each(org/jruby/RubyArray.java:2077)
at RUBY.<main>(<script>:4)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels