You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TTBOMK, we must use the NativeLibrary.getGlobalVariableAddress() method. But how to get the NativeLibrary instance from the Library interface instance? Currently, it appears that there is no way to do this – except by manually using getInvocationHandler() from java.lang.reflect.Proxy to get the Handler instance out of the Library interface, and then call getNativeLibrary() on it. This is not trivial to figure out at all. I was only able to figure it out with some help from another user on StackOverflow. Also, even if you know that java.lang.reflect.Proxy must be used, doing this is unnecessarily cumbersome 😩
BTW: Loading the library for a second time, via NativeLibrary.getInstance() method, does not seem like a good solution.
As the title says, please provide a method for getting the
NativeLibrary
instance from aLibrary
interface instance!Background
The idiomatic way of using JNA is like this:
But how do we access global variables from here?
TTBOMK, we must use the
NativeLibrary.getGlobalVariableAddress()
method. But how to get theNativeLibrary
instance from theLibrary
interface instance? Currently, it appears that there is no way to do this – except by manually usinggetInvocationHandler()
fromjava.lang.reflect.Proxy
to get theHandler
instance out of theLibrary
interface, and then callgetNativeLibrary()
on it. This is not trivial to figure out at all. I was only able to figure it out with some help from another user on StackOverflow. Also, even if you know thatjava.lang.reflect.Proxy
must be used, doing this is unnecessarily cumbersome 😩BTW: Loading the library for a second time, via
NativeLibrary.getInstance()
method, does not seem like a good solution.Request
Please see my PR here:
#1612
Usage Example
The text was updated successfully, but these errors were encountered: