本地环境:win7(32位) + jdk1.8(32位) + jna-4.2.1.jar;
代码:
IJnaTest.java :
IJnaTest instanceDll=(IJnaTest) Native.loadLibrary("Dll1", IJnaTest.class);
void MAIN1_mp_XAJMAIN(String Address,FloatByReference AA,IntByReference Cla);
Test.java:
public static void main(String[] args) {
String Address="D://";
FloatByReference AA=new FloatByReference(12.2f);
IntByReference Cla=new IntByReference(1);
IJnaTest it=IJnaTest.instanceDll;
it.MAIN1_mp_XAJMAIN(Address, AA, Cla);
}
报错信息如下:
Exception in thread "main" java.lang.Error: Invalid memory access
at com.sun.jna.Native.invokeVoid(Native Method)
at com.sun.jna.Function.invoke(Function.java:374)
at com.sun.jna.Function.invoke(Function.java:323)
at com.sun.jna.Library$Handler.invoke(Library.java:236)
at com.sun.proxy.$Proxy0.MAIN1_mp_XAJMAIN(Unknown Source)
at com.jna.Test.main(Test.java:40)
求大神搭救!!