Created
January 21, 2011 02:17
-
-
Save cowboyd/789134 to your computer and use it in GitHub Desktop.
trying to do an instance_eval on any old object from java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package spike; | |
import org.jruby.embed.ScriptingContainer; | |
public class Spike { | |
public static void main(String[] args) { | |
ScriptingContainer container = new ScriptingContainer(); | |
Object someInstance = container.runScriptlet("Object.new"); | |
container.callMethod(someInstance, "instance_eval", "self", "<eval>", 1); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.lang.NullPointerException | |
at org.jruby.runtime.ThreadContext.preExecuteUnder(ThreadContext.java:1304) | |
at org.jruby.RubyBasicObject.evalUnder(RubyBasicObject.java:1897) | |
at org.jruby.RubyBasicObject.specificEval(RubyBasicObject.java:1851) | |
at org.jruby.RubyObject.instance_eval(RubyObject.java:1212) | |
at org.jruby.RubyObject$i_method_multi$RUBYINVOKER$instance_eval.call(org/jruby/RubyObject$i_method_multi$RUBYINVOKER$instance_eval.gen:65535) | |
at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrOneOrTwoOrThreeBlock.call(JavaMethod.java:488) | |
at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:178) | |
at org.jruby.RubyClass.finvoke(RubyClass.java:665) | |
at org.jruby.javasupport.util.RuntimeHelpers.invoke(RuntimeHelpers.java:552) | |
at org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.callEachType(EmbedRubyObjectAdapterImpl.java:448) | |
at org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.call(EmbedRubyObjectAdapterImpl.java:392) | |
at org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.callMethod(EmbedRubyObjectAdapterImpl.java:332) | |
at org.jruby.embed.ScriptingContainer.callMethod(ScriptingContainer.java:1325) | |
at spike.Spike.main(Spike.java:9) |
Thanks for the explanation and workaround. Where should I file it.?
Sorry for not responding this. I fixed this bug in rev. 34aec51. So, you don't need to set the attribute any more.
Thanks for reporting the bug!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems to come from pushing a scope for sharing local variables. As far as I tested, when sharing variables feature was off, the exception wasn't raised. This is a bug of embedding API. Please file this. Workaround is setting sharing variables off like below:
This attribute can be changed in each runScriptlet/callMethod by setting the value just before those methods.