Unexpected byte[] parameter conversion when calling java method

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Unexpected byte[] parameter conversion when calling java method

Michael Kunz
Hello,

I'm having problems calling a Java method call(byte[]... data) from
groovy 2.4.12.
I'm trying to call it with a single byte[] value from groovy like this:
byte[] data = [0,1,2,3,4,5,6,7]
TestJava.call(data)

I was expecting to receive a byte[][] data = {{0,1,2,3,4,5,6,7}} in Java
but instead have a split array of the form byte[][] data =
{{0},{1},{2},{3},{4},{5},{6},{7}} which doesn't make sense to me.
A full example is available at
https://gist.github.com/protogenes/93a5d76075b45ba5a946034820f03c76

What is the expected behaviour and why? Can I change the Java method
signature in a way so that the arrays are preserved?

Regards, Michael
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected byte[] parameter conversion when calling java method

Jochen Theodorou


Am 20.10.2017 um 09:51 schrieb Michael Kunz:

> Hello,
>
> I'm having problems calling a Java method call(byte[]... data) from
> groovy 2.4.12.
> I'm trying to call it with a single byte[] value from groovy like this:
> byte[] data = [0,1,2,3,4,5,6,7]
> TestJava.call(data)
>
> I was expecting to receive a byte[][] data = {{0,1,2,3,4,5,6,7}} in Java
> but instead have a split array of the form byte[][] data =
> {{0},{1},{2},{3},{4},{5},{6},{7}} which doesn't make sense to me.
> A full example is available at
> https://gist.github.com/protogenes/93a5d76075b45ba5a946034820f03c76
>
> What is the expected behaviour and why? Can I change the Java method
> signature in a way so that the arrays are preserved?

the expected behavior is what you expect {{0,1,2,3,4,5,6,7}}

bye Jochen