|
[jruby-user] JRuby array to Java array: msg#00189lang.jruby.user
My first two attempts got rejected, so hopefully this will get through... I'm using the Erlang JInterface library (http://www.erlang.org/doc/apps/jinterface/index.html ) to communicate between my ruby code and my erlang code. One of the key objects in this library is the OtpErlangTuple, which takes an array of OtpErlangObject instances as the argument to its constructor. Looking through the Jira bug reports, I found that you can make a JRuby java array like so: ary = OtpErlangObject[2].new And then assignment is just like assignment to any other array, and the tuple can be constructed with ary as its constructor argument. What I'm wondering is why this can't be done in a more ruby-ish fashion. What I want to be able to do is: tup = OtpErlangTuple.new [ firstErlObject, secondErlObject, etc ] but the JRuby array is not a Java array, so this gives a NameError. JRuby arrays has a to_java method, which converts the org.jruby.RubyArray into a java.lang.Object, but that's still not a valid array. I've also tried tup = OtpErlangTuple.new OtpErlangObject[2].new( [ firstErlObject, secondErlObject ] ) but that that gives the puzzling message "NativeException: java.lang.IllegalArgumentException: array element type mismatch." All the elements in the JRuby array are OtpErlangObjects, so I don't know what the type mismatch is. Is there a clean way to convert a JRuby array into a Java one, or do I just have to make the array using the Object[size].new and assign all the elements by hand? |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [jruby-user] Unit test rollback and autocommit on sqlserver 2005: 00189, Jeffrey Wong |
|---|---|
| Next by Date: | Re: [jruby-user] Running watir on jruby: 00189, Charles Oliver Nutter |
| Previous by Thread: | [jruby-user] Unit test rollback and autocommit on sqlserver 2005i: 00189, Jeffrey Wong |
| Next by Thread: | Re: [jruby-user] JRuby array to Java array: 00189, Bill Dortch |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |