Forum: JRuby Java arrays in jruby

B97f192e676f1a67e0ef18f022671406?d=identicon&s=25 Rodrigo Botafogo (Guest)
on 2012-07-06 18:31
(Received via mailing list)
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 Botafogo
Integrando TI ao seu negcio
F1d37642fdaa1662ff46e4c65731e9ab?d=identicon&s=25 Charles Nutter (headius)
on 2012-07-08 01:10
(Received via mailing list)
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
B97f192e676f1a67e0ef18f022671406?d=identicon&s=25 Rodrigo Botafogo (Guest)
on 2012-07-09 17:08
(Received via mailing list)
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 Nutter
<headius@headius.com> 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 Botafogo
Integrando TI ao seu negcio
This topic is locked and can not be replied to.