in thread "main" java.lang.Error: Invalid memory access
// Original C code
void get_devices(struct Device[], int size);
// Equivalent JNA mapping
int size = ...
Device[] devices = new Device[size];
lib.get_devices(devices, devices.length);
Alternatively, you can reallocate a single Structure instance into an array as follows:
Device dev = new Device();
// As an array of Structure
Structure[] structs = dev.toArray(size);
// As an array of Device
Device[] devices = (Device[])dev.toArray(size);
When used first approach it gives me null pointer memory exception although I have written constructor with allocatememory(size);The second approach is what I used in program, but failed.
I dont think Structure.ByValue.toArray() makes any sense here.