刚学JNA,主要看了出现了一下破问题,不懂啊,那位大侠教教我怎么根据这个错误来跳程序啊
run:
#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x03097ac7, pid=2224, tid=2640
#
# Java VM: Java HotSpot(TM) Client VM (11.2-b01 mixed mode, sharing windows-x86)
# Problematic frame:
# C [client.dll+0x27ac7]
#
# An error report file with more information is saved as:
# D:\NetBean\JNATest1\hs_err_pid2224.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Java Result: 1
还有就是这个错误开始没有的,同一个程序跑了第5遍的时候才这样的帮帮忙,谢谢啦
run:
#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x03097ac7, pid=2224, tid=2640
#
# Java VM: Java HotSpot(TM) Client VM (11.2-b01 mixed mode, sharing windows-x86)
# Problematic frame:
# C [client.dll+0x27ac7]
#
# An error report file with more information is saved as:
# D:\NetBean\JNATest1\hs_err_pid2224.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Java Result: 1
还有就是这个错误开始没有的,同一个程序跑了第5遍的时候才这样的帮帮忙,谢谢啦
{ DUABind是DUA向DSA注册函数,该函数完成向给定的DSA注册的功能。
入口参数:puserinfo 指向结构TUserInfo 的指针,调用前把结构中的成员赋值;
dsaip_address DSA所在的服务器的IP地址;
port_no 证书服务进程公布的端口号;
bindseconds 注册所需的最大秒数。
出口参数:psock 指向SOCKET类型的变量地址,若注册成功后,则本函数负责填写;
返回值:0 表示注册成功,1 表示用户身份非法,2 打请求包错误,
3 网络连接失败,4 打上三层数据包错误,
5 注册信息发送失败,6 注册信息接收失败或超时
7 解上三层数据包错误,8 解注册结果包错误,
9 收到的信息不认识 }
function DUABind(puserinfo : PUserInfo;
dsaip_address : pchar;
port_no : integer;
var psock : TSocket;
bindseconds : integer
):integer;cdecl;external CLIENT_DLLNAME name 'DUABind';
其中的数据结构如下:
TUserInfo =record
Name :array[0..MAX_RDN_LENGTH-1] of char; //注册用户的RDN名字
Password :array[0..MAX_PASSWORD_LENGTH-1] of char; //未保护的口令
end;
PUserInfo=^TUserinfo;
下面是我写的
1、
对数据结构的声明
public class TUserInfo extends Structure{
public String Name = null;
public String Password = null;
}
对dll中函数的声明
public interface SimpleDUA extends StdCallLibrary {
SimpleDUA INSTANCE = (SimpleDUA)Native.loadLibrary("client", SimpleDUA.class);
int DUABind(TUserInfo puserinfo,
String dsaip_address,
int port_no,
Socket psock,
int bindseconds);
......
}2、java中对接口simpleDUA方法的使用:public class JNADUA {
public SimpleDUA getDUAInstance(){
SimpleDUA lib = SimpleDUA.INSTANCE;
return lib;
}public int DUABind(simpleDUA lib,
TUserInfo puserinfo,
String dsaip_address,
int port_no,
Socket psock,
int bindseconds){
int duabind = lib.DUABind(puserinfo, dsaip_address, port_no, psock, bindseconds);
return duabind;
}
}3、对数据结构的初始化public class Structinitial { public TUserInfo initUserInfo(){
TUserInfo UserInfo = new TUserInfo();
UserInfo.Name = "administrator";
UserInfo.Password = "12345";
return UserInfo;
}
}
4、main函数调用public class Main implements invariable{ /**
* @param args the command line arguments
*/
public static void main(String[] args){
JNADUA jnaDUA = new JNADUA();
simpleDUA lib = jnaDUA.getDUAInstance(); Structinitial init = new Structinitial();
TUserInfo UserInfo = init.initUserInfo(); Socket sock = null;
int testbind = jnaDUA.DUABind(lib, UserInfo, dsaip_address, port_no, sock, MAXTIMEOUT);
System.out.print(testbind);
}
}
出现的错误就是最开始的那样了。
哪个地方有问题?谢谢啦