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.
Jim M. (Guest)
on 2009-01-05 23: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 M., removed_email_address@domain.invalid, 
removed_email_address@domain.invalid
http://www.io.com/~jimm/

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

    http://xircles.codehaus.org/manage_email
Thomas E Enebo (Guest)
on 2009-01-06 17: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 M. <removed_email_address@domain.invalid> 
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: removed_email_address@domain.invalid , 
removed_email_address@domain.invalid

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

    http://xircles.codehaus.org/manage_email
Jim M. (Guest)
on 2009-01-06 19:52
(Received via mailing list)
On Tue, Jan 6, 2009 at 10:36 AM, Thomas E Enebo 
<removed_email_address@domain.invalid>
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 M., removed_email_address@domain.invalid, 
removed_email_address@domain.invalid
http://www.io.com/~jimm/

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

    http://xircles.codehaus.org/manage_email
Jim M. (Guest)
on 2009-01-06 19: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 M. <removed_email_address@domain.invalid>
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 M., removed_email_address@domain.invalid, removed_email_address@domain.invalid
> http://www.io.com/~jimm/
>



--
Jim M., removed_email_address@domain.invalid, 
removed_email_address@domain.invalid
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.