Forum: JRuby Exception trying to run Ruby 1.9 from Java

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.
F8101d1b395ef58feb1d5c99bf9356df?d=identicon&s=25 Jim Menard (Guest)
on 2009-01-05 22:36
(Received via mailing list)
When I try running Ruby 1.9 from withing Java (JRuby 1.1.6), I see the
following exception:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
        at
org.jruby.ast.executable.YARVMachine.pop(YARVMachine.java:188)
        at
org.jruby.ast.executable.YARVMachine.exec(YARVMachine.java:618)
        at
org.jruby.ast.executable.YARVMachine.exec(YARVMachine.java:262)
        at
org.jruby.ast.executable.YARVCompiledRunner.run(YARVCompiledRunner.java:89)
        at org.jruby.Ruby.runYarv(Ruby.java:572)
        at org.jruby.Ruby.runNormally(Ruby.java:470)
        at
ed.lang.ruby.RuntimeEnvironment.commonRun(RuntimeEnvironment.java:171)
        at ed.lang.ruby.RubyJxpSource._doCall(RubyJxpSource.java:57)
...

The only thing I've changed is making the yarvCompile argument to
Ruby#runNormally true instead of false. Here's a simplified version of
my
code:

  Ruby runtime = ...;
  Node node = runtime.parseFile(bytesFromScriptString, ...);
  boolean yarvCompile = true;
  // yarvCompile is false for Ruby 1.8 (works), true for Ruby 1.9
(fails)
  runtime.runNormally(node, yarvCompile);

Any idea what I'm doing wrong?

Funny thing is, when I look at the source code to see what the '--1.9'
flag
does, I can't find it anywhere in RubyInstanceConfig#processArgument().

Jim
--
Jim Menard, jimm@io.com, jim.menard@gmail.com
http://www.io.com/~jimm/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
13313ac2ec7ba7c43b1b952db034ff3b?d=identicon&s=25 Thomas E Enebo (Guest)
on 2009-01-06 16:36
(Received via mailing list)
You want RubyInstanceConfig.compatVersion to be set to
CompatVersion.Ruby1_9.

The yarvcompile stuff should be yanked out of that method.  It was an
experimental yarv machine which is unrelated to 1.9 support.

-Tom

On Mon, Jan 5, 2009 at 3:35 PM, Jim Menard <jim.menard@gmail.com> wrote:
>        at ed.lang.ruby.RuntimeEnvironment.commonRun(RuntimeEnvironment.java:171)
>  // yarvCompile is false for Ruby 1.8 (works), true for Ruby 1.9 (fails)
> http://www.io.com/~jimm/
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>



--
Blog: http://www.bloglines.com/blog/ThomasEEnebo
Email: enebo@acm.org , tom.enebo@gmail.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F8101d1b395ef58feb1d5c99bf9356df?d=identicon&s=25 Jim Menard (Guest)
on 2009-01-06 18:52
(Received via mailing list)
On Tue, Jan 6, 2009 at 10:36 AM, Thomas E Enebo <tom.enebo@gmail.com>
wrote:
> You want RubyInstanceConfig.compatVersion to be set to CompatVersion.Ruby1_9.
>
> The yarvcompile stuff should be yanked out of that method.  It was an
> experimental yarv machine which is unrelated to 1.9 support.

Thank you.

There is no public method in RubyInstanceConfig to set compatVersion
directly; only the "--compat" command line arg and the
jruby.compat.version setting.

Wouldn't it make sense to create a public setCompatVersion method? I
think I'm going to add that as a feature request in JIRA.

Jim

>>        at org.jruby.ast.executable.YARVMachine.exec(YARVMachine.java:262)
>>
>>
>>
>
>    http://xircles.codehaus.org/manage_email
>
>
>



--
Jim Menard, jimm@io.com, jim.menard@gmail.com
http://www.io.com/~jimm/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F8101d1b395ef58feb1d5c99bf9356df?d=identicon&s=25 Jim Menard (Guest)
on 2009-01-06 18:59
(Received via mailing list)
Submitted, including the code for RubyInstanceConfig#setCompatVersion

http://jira.codehaus.org/browse/JRUBY-3287

Jim

On Tue, Jan 6, 2009 at 12:51 PM, Jim Menard <jim.menard@gmail.com>
wrote:
> jruby.compat.version setting.
>>> When I try running Ruby 1.9 from withing Java (JRuby 1.1.6), I see the
>>>        at ed.lang.ruby.RubyJxpSource._doCall(RubyJxpSource.java:57)
>>>  runtime.runNormally(node, yarvCompile);
>>>
>> --
>
>
>
> --
> Jim Menard, jimm@io.com, jim.menard@gmail.com
> http://www.io.com/~jimm/
>



--
Jim Menard, jimm@io.com, jim.menard@gmail.com
http://www.io.com/~jimm/

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.