Forgot to put the list in CC: Patrick
---------- Forwarded message ---------- From: Patrick LeBoutillier <patrick.leboutill...@gmail.com> Date: Wed, Mar 9, 2011 at 8:17 PM Subject: Re: Passing byte arrays with Inline::Java To: Alessandro Ranellucci <a...@cpan.org> Hi Alessandro, On Wed, Mar 9, 2011 at 2:28 PM, Alessandro Ranellucci <a...@cpan.org> wrote: > Hi all, > > thanks to the wonderful Inline::Java module I recently published these > bindings: http://search.cpan.org/perldoc?Net::RabbitMQ::Java > > However I'm running into a problem. My Java library needs strings to be > passed as byte arrays, so I'm using the following snippet: > > [ unpack("C*", $string) ] > > that creates an arrayref of scalars holding single bytes. This is very > inefficient but it seemed to work... until I tried to pass a string larger > than ~156 bytes. It fails with the following error: > > [perl][3] error trying to fit args to prototype: 195 out of range for type > byte at /usr/local/lib/perl/5.10.1/Inline/Java/Array.pm line 543 > > What does this mean? Any workaround? Bytes are signed in Java. The message is telling you that (ascii code) 195 is too large to fit in a java Byte (the maximum value is 127, see http://download.oracle.com/javase/6/docs/api/java/lang/Byte.html) Try unpacking with "c*" instead and see if it works. Patrick > > Also, would it be possible to add an automatic conversion from Perl scalars > to Java byte arrays? > > Thank you and keep up the good work! > > - alessandro. > > -- ===================== Patrick LeBoutillier Rosemère, Québec, Canada -- ===================== Patrick LeBoutillier Rosemère, Québec, Canada