Java arrays in jruby

Im trying to create and pass a java array to a java method.
According to the CallingJavaFromJRuby, one could just use the to_java
method to create the java array. However, using to_java is not
creating a Java array but org.jruby.java.proxies.ArrayJavaProxy. If I
pass the proxy array to the java method that requires a java array,
the java method issues an exception:

     NameError: no method 'addGlobalAttribute' for arguments

(org.jruby.RubyString, org.jruby.java.proxies.ArrayJavaProxy) on
Java::UcarNc2::NetcdfFileWriteable

Am I doing something wrong?

Thanks,

ā€“
Rodrigo B.
Integrando TI ao seu negcio

The error message is unfortunately misleading here (and Iā€™d appreciate a
bug report so we remember to fix it in 1.7 timeframe). You are
actually
creating a Java array, but for Ruby to handle it like a Ruby object we
wrap
it in another object of type ArrayJavaProxy.

The error is probably caused by calling a method with the wrong type of
argument. How are you creating the Java array via to_java? (show code,
please)

  • Charlie

Hi Charles,

Thanks for your reply. Ill file the bug report. You are right.
Ive figured the problem out. The method Im calling is expecting an
Array, but not a Java Array. It is the array type defined in the
library Im using.

Thanks for your help.

Rodrigo

On Sun, Jul 8, 2012 at 12:09 AM, Charles Oliver N.
[email protected] wrote:

     NameError: no method 'addGlobalAttribute' for arguments

Integrando TI ao seu negcio


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

ā€“
Rodrigo B.
Integrando TI ao seu negcio