RockTheStar
RockTheStar

Reputation: 680

JNA direct vs interface mapping?

Sorry, this maybe a basic question. What are the difference between JNA direct mapping and interface mapping?

Is my interpretation correct:

Thanks in advance!

Upvotes: 6

Views: 2038

Answers (1)

technomage
technomage

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

Related Questions