-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added static helper methods for getting the underlying NativeLibrary instance from a Library interface instance or from a "registered" class. #1612
Conversation
Makes sense to me. Another usecase is if you need to manually unload the library you need access to the NativeLibrary. However you are only covering the "InvocationHandler" implementation, but JNA also supports a direct mapping, where there is no invocation handler, but adaption is done on the native level. See A test showing, that the code indeed works for both cases should be added to the unittests. Please also ensure, that you add an entry to the When you update the commit, please also ensure, that the author information is complete. There is an email, but no real name, please update that. |
6a141f1
to
4137211
Compare
PR has been updated as desired (I hope so) 😏 |
6388436
to
a5269a6
Compare
…rapped NativeLibrary instance + added static helper method to the Native class for getting the NativeLibrary instance that a "registered" class is bound to.
@serinana47 thank you for the update. I think we need another round. Please have a look here: https://github.com/matthiasblaesing/jna/commits/pr-1612/
Feel free to integrate into your variant if you agree. The commit still does not hold you real name. Please run |
Thank you for your response.
|
I'll finish this then myself. I won't merge changes without realnames. Sorry. For the getNativeFile in Library: I don't take that argument. As a user you don't deal with |
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: