Invalid memory access when using JNA in JAVA -


i trying use jna call function in mysms.dll read sms device. sms details read smessage, sfrom , stime. however, below error.

no idea on causing error. please help. many thanks.

c:\users\chi\desktop\sms_pool\install\sms.dll\mysms.dll>set classpath=.;c:\program files (x86)\java\jre7\lib\* c:\users\chi\desktop\sms_pool\install\sms.dll\mysms.dll>"c:\program files (x86)\java\jre7\bin\java" smstest exception in thread "main" java.lang.error: invalid memory access     @ com.sun.jna.native.invokeint(native method)     @ com.sun.jna.function.invoke(function.java:371)     @ com.sun.jna.function.invoke(function.java:315)     @ com.sun.jna.library$handler.invoke(library.java:212)     @ com.sun.proxy.$proxy0.readsms(unknown source)     @ smstest.main(smstest.java:35) 

api file dll:

_declspec(dllexport) bool _stdcall readsms(int comport, int baud, int nindex, char* smessage, char* sfrom, char* stime, bool bdel); 

java code:

import com.sun.jna.library;   import com.sun.jna.native;   import com.sun.jna.platform;    public class smstest {       public interface clibrary extends library {           clibrary instance = (clibrary) native.loadlibrary(  platform.iswindows() ? "mysms" : "c", clibrary.class);           boolean readsms(int comport, int baud, int nindex, string smessage, string sfrom, string stime, boolean bdel);     }    public static void main(string[] args) {   try{   string a= new string();   string b= new string();   string c = new string();   system.out.println(clibrary.instance.readsms(6,115200, 1, a,b,c,false));  }catch (exception e){ } }    } 

notice _stdcall in native declaration? that's indication jna interface needs implement stdcalllibrary interface ensure uses proper calling convention.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -