Description
I have a Union inside a Struct (with other primitive fields). The struct I implements Structure.ByReference
and initialize it with a Pointer
.
Inside the Union there is a few Structure
with different size.
It works correctly when I do a read()
on the outer Structure
after setting the Union to the correct type. However the performance is 2-3x slower than when I process the Union separately.
By separately I mean I need to break the Union into normal Structure and dispatch them based on input information and init with a Pointer and an offset. The faster method however is not good since the offset in 32-bit machine and 64-bit machine is different.
So I guess the problem is the offset calculation internally of JNA. I am not sure if this is a known problem or I was doing it the wrong way. I tested with JNA 4.0.0 from the download link.