I'm trying to create a array of my class (that extends JNA's Structure) to pass it for a DLL function. I have the values readed from a database to a ArrayList, and now I need to put them into a array. First, I tried to use the toArray() method of ArrayList, but it return me the following exception when I call the native function:
java.lang.IllegalArgumentException: Structure array elements must use contiguous memory (bad backing address at Structure array index 1)
If I simply set a new array with the same size as the ArrayList, when I will set the 'fields' of the struct in my class, it returns me a NullPointerException.
Someone can help me to solve this?
Structure.toArray() provides you with a block of contiguously allocated Structure objects. Create this array of Structure prior to initializing it from your ArrayList of "values".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With