使用 JNA 从 java crash VM 调用 c,谁能告诉我为什么会这样?哪里错了?
c代码:
int Encode(char* systemId, char* account, char* userName, char* tradingPwd, char* expansion, char* ipAddress, char* userAgent, char * encryptedIn, int encrySize);
在 x86_64 x86_64 x86_64 GNU/Linux 机器中将 c 编译为共享的 lig libTestEncode.so,Encode 方法只是对一些字符串进行编码,并将其返回给 java。
爪哇代码:
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary) Native.loadLibrary("TestEncode", CLibrary.class);
int Encode(String systemId,String account,String userName,String tradingPwd, String expansion, String ipAddress, String userAgent, byte[] encryptedIn, int encryptSize);
}
public static void main(String args[]) {
Properties p = new Properties();
byte [] text = new byte[1024];
int retCd =CLibrary.INSTANCE.Encode("NRI","userID","username","password","","","",text, 1024);
System.out.println(Native.toString(text));
System.out.println("-----");
}