Reputation: 680
Sorry, this maybe a basic question. What are the difference between JNA direct mapping and interface mapping?
Is my interpretation correct:
Direct mapping: use the library object directly (like static main in Java)
Interface mapping: create an instance of the library object.
Thanks in advance!
Upvotes: 6
Views: 2038
Reputation: 10069
Direct mapping directly binds your Java methods (declared with the native
modifier) to native code which attempts to use the call stack as-is. Direct mapping is most effective if you restrict your function arguments and return values to primitive types (the Pointer
type may be considered primitive).
The interface mapping uses a Proxy
and dynamically translates Java function signatures into a generic native entry point with a list of arguments which must subsequently be translated into native primitives. It's more flexible w/r/t translating Java types to and from native, but can be much slower due to the runtime translation of arguments.
Upvotes: 5