On Dec 17, 2007, at 11:44 PM, Rui Caridade wrote:
Hello.
I have a function that returns a list of Strings with the cdrom id
names on the pc (below)
char ** getCDRomDevices();
But whenever i try to call it from java , whether with byte [ ] [ ]
or String [ ] i get this error (the error below refers when i say
within java the function returns a byte [ ] [ ] )
Exception in thread "main" java.lang.IllegalArgumentException:
Unsupported return type class [[B
at com.sun.jna.Function.invoke(Function.java:335)
at com.sun.jna.Function.invoke(Function.java:229)
at com.sun.jna.Library$Handler.invoke(Library.java:170)
at $Proxy0.getCDRomDevices(Unknown Source)
at test.main(test.java:43)
This is because there is no way to know automatically how big is the
returned array. If you return Pointer, then you can use
Pointer.getPointerArray(0, length) if you know the length or
Pointer.getPointer(Pointer.SIZE * index) until you're done reading
individual values.
One other thing. I'm getting a file from the cdrom into something
like this (char * file), what would be the best way to map this.I
later want to transfer this data to a ByteBuffer (Direct).
You can pass a Buffer as an argument, so you can create your direct
ByteBuffer and pass it in.