Search code examples
javapointersjna

JNA Pointer class: How to set Pointer object to point to another class?


I am trying to create a single Pointer object using the JNA library and set it to "point" to an object of a custom data type defined.

Can someone please explain how to do this?

CustomType ctype = new CustomType();
Pointer pointer = new Pointer(ctype);

This does not work. I have tried searching and googling but none of the questions I found have shown what I need.


Solution

  • Okay, so as I stated in the comment, the sollution was to make the custom data type a subclass of JNA structure which has a getPointer() method.