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:
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 theLibraryinterface:Useful, if the
Library-based interface was loaded viaNative.load()but we need to access theNativeLibraryinstance.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.Proxymust 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 theNativeLibraryinstance from aLibraryinterface instance)It will be used like this: