1 ,当前路径是在项目下,而不是 bin 输出目录下。
2 ,数据结构的对应关系:
Java—C和操作系统数据类型的对应表
Java Type | C Type | Native Representation |
boolean | int | 32-bit integer (customizable) |
byte | char | 8-bit integer |
char | wchar_t | platform-dependent |
short | short | 16-bit integer |
int | int | 32-bit integer |
long | long long, __int64 | 64-bit integer |
float | float | 32-bit floating point |
double | double | 64-bit floating point |
Buffer | pointer | platform-dependent (32- or 64-bit pointer to memory) |
<T>[] (array of primitive type) | pointer | 32- or 64-bit pointer to memory (argument/return) |
除了上面的类型, JNA 还支持常见的数据类型的映射。 | ||
char* | NUL-terminated array (native encoding or jna.encoding ) | |
WString | wchar_t* | NUL-terminated array (unicode) |
char** | NULL-terminated array of C strings | |
WString[] | wchar_t** | NULL-terminated array of wide C strings |
Structure | struct* | pointer to struct (argument or return) ( or explicitly ) |
Union | union | same as Structure |
Structure[] | struct[] | array of structs, contiguous in memory |
Callback | <T> (*fp)() | function pointer (Java or native) |
NativeMapped | varies | depends on definition |
NativeLong | long | platform-dependent (32- or 64-bit integer) |
PointerType | pointer | same as Pointer |
Unsigned types use the same mappings as signed types. C enums are usually interchangeable with "int".