Added static helper methods for getting the underlying NativeLibrary instance from a Library interface instance or from a "registered" class. #1612
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds static method
getNativeLibrary()
to theLibrary
interface:Useful, if the
Library
-based interface was loaded viaNative.load()
but we need to access theNativeLibrary
instance.One important use-case is the
NativeLibrary.getGlobalVariableAddress()
method!I'm not aware of another way to get a global variable from the
Library
-based interface. If there is, please tell me 😏(BTW: It is not trivial to figure out that
getInvocationHandler()
fromjava.lang.reflect.Proxy
must be used to get theHandler
, which then can can be used to get theNativeLibrary
. This alone is enough reason to provide a dedicated method in the JNA interface for getting theNativeLibrary
instance from aLibrary
interface instance)It will be used like this: