关于 java:Options in Native.loadLibrary

Options in Native.loadLibrary

我已经在 JNA 工作了一段时间了。但有一件事,我还没有明白。例如,在加载库时:

1
2
3
Map<String, Integer> options = new HashMap<String, Integer>();
options.put(Library.OPTION_CALLING_CONVENTION, StdCallLibrary.STDCALL_CONVENTION);
this.EDSDK = (EdSdkLibrary) Native.loadLibrary("EDSDK/dll/EDSDK.dll", EdSdkLibrary.class, options);

上面的options到底是什么?

api 说:

public static Object loadLibrary(String name,
Class interfaceClass,
Map options)

Load a library interface from the given shared library, providing the explicit interface class and a map of options for the library. If no library options are detected the map is interpreted as a map of Java method names to native function names.
If name is null, attempts to map onto the current process.

上面的map of options for the library是什么意思?


这是一个包含图书馆选项的地图。一个这样的选项是函数映射器。
您可以在下面找到一个示例:

1
2
3
4
5
    System.setProperty("jna.library.path","SiUSBXp.dll");
    HashMap<String, StdCallFunctionMapper> optionMap = new HashMap<String,    StdCallFunctionMapper>();
    StdCallFunctionMapper myMapper = new StdCallFunctionMapper();
    optionMap.put(Library.OPTION_FUNCTION_MAPPER, myMapper);
    INSTANCE = (SiUSBXp) Native.loadLibrary("SiUSBXp", SiUSBXp.class, optionMap);