Forum: JRuby Java arrays in jruby

Posted by 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
Posted by 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
Posted by 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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.