java调用dll 堆栈溢出
我在做一个RFID读卡器,在调用其中的初始化函数的时候 总归是爆出堆栈溢出的错误。
请问如何解决? 用到了 JNA的技术 dll文件问 rfid.dll
java代码如下:
public class EcardReaderImpl {
/**
* 连接读写器
* @param port
* @return
* @throws NativeException
* @throws IllegalAccessException
*/
public String ConnectionReader(int port) throws NativeException, IllegalAccessException{
JNative n = null;
try{
//1.创建JNative对象
n = new JNative("rfid.dll","RFID_Startup");//初始化
//2.设置函数返回值类型
n.setRetVal(Type.INT);
//3.设置参数类型
int i=0;
n.setParameter(i++, port);
//4.执行函数
n.invoke();
//5.获取函数返回值
return n.getRetVal();
}finally{
if(n!=null){
n.dispose();
}
}
}
/**
* 关闭读卡器
* @return
* @throws NativeException
* @throws IllegalAccessException
*/
public String CloseReader() throws NativeException, IllegalAccessException{
JNative n = null;
try{
//1.创建JNative对象
n = new JNative("rfid.dll","RFID_Shutdown");
//设置函数返回值类型
n.setRetVal(Type.INT);
//设置参数类型
//执行函数
n.invoke();
//获取函数返回值
return n.getRetVal();
}finally{
if(n!=null){
n.dispose();
}
}
}
public static void main(String[] args)throws NativeException, IllegalAccessException {
EcardReaderImpl impl = new EcardReaderImpl();
System.out.println("连接读卡器=="+impl.ConnectionReader(1));
System.out.println("关闭读写器=="+impl.CloseReader());
}
}
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x024de400 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=9480, stack(0x04970000,0x049c0000)]
0x024d9000 JavaThread "CompilerThread0" daemon [_thread_blocked, id=1528, stack(0x048e0000,0x04930000)]
0x024d0c00 JavaThread "Attach Listener" daemon [_thread_blocked, id=10784, stack(0x04850000,0x048a0000)]
0x024c8400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=10804, stack(0x047c0000,0x04810000)]
0x02482800 JavaThread "Finalizer" daemon [_thread_blocked, id=11144, stack(0x04730000,0x04780000)]
0x02481400 JavaThread "Reference Handler" daemon [_thread_blocked, id=9772, stack(0x046a0000,0x046f0000)]
=>0x02579800 JavaThread "main" [_thread_in_native, id=8808, stack(0x002c0000,0x00310000)]
Other Threads:
0x0247f800 VMThread [stack: 0x04610000,0x04660000] [id=7660]
0x024e7000 WatcherThread [stack: 0x04a00000,0x04a50000] [id=10316]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 960K, used 499K [0x24230000, 0x24330000, 0x24710000)
eden space 896K, 55% used [0x24230000, 0x242ace88, 0x24310000)
from space 64K, 0% used [0x24310000, 0x24310000, 0x24320000)
to space 64K, 0% used [0x24320000, 0x24320000, 0x24330000)
tenured generation total 4096K, used 0K [0x24710000, 0x24b10000, 0x28230000)
the space 4096K, 0% used [0x24710000, 0x24710000, 0x24710200, 0x24b10000)
compacting perm gen total 12288K, used 430K [0x28230000, 0x28e30000, 0x2c230000)
the space 12288K, 3% used [0x28230000, 0x2829b870, 0x2829ba00, 0x28e30000)
ro space 8192K, 67% used [0x2c230000, 0x2c792f30, 0x2c793000, 0x2ca30000)
rw space 12288K, 53% used [0x2ca30000, 0x2d0a0180, 0x2d0a0200, 0x2d630000)
Dynamic libraries:
0x00400000 - 0x00424000 D:\program files (x86)\Java\jdk1.6.0_10\bin\javaw.exe
0x777d0000 - 0x77950000 C:\Windows\SysWOW64\ntdll.dll
0x76b00000 - 0x76c10000 C:\Windows\syswow64\kernel32.dll
0x75700000 - 0x75746000 C:\Windows\syswow64\KERNELBASE.dll
0x76a60000 - 0x76b00000 C:\Windows\syswow64\ADVAPI32.dll
0x76510000 - 0x765bc000 C:\Windows\syswow64\msvcrt.dll
0x76d80000 - 0x76d99000 C:\Windows\SysWOW64\sechost.dll
0x771a0000 - 0x77290000 C:\Windows\syswow64\RPCRT4.dll
0x75330000 - 0x75390000 C:\Windows\syswow64\SspiCli.dll
0x75320000 - 0x7532c000 C:\Windows\syswow64\CRYPTBASE.dll
0x76c10000 - 0x76d10000 C:\Windows\syswow64\USER32.dll
0x76480000 - 0x76510000 C:\Windows\syswow64\GDI32.dll
0x75750000 - 0x7575a000 C:\Windows\syswow64\LPK.dll
0x75390000 - 0x7542d000 C:\Windows\syswow64\USP10.dll
0x76d10000 - 0x76d70000 C:\Windows\system32\IMM32.DLL
0x765c0000 - 0x7668c000 C:\Windows\syswow64\MSCTF.dll
0x7c340000 - 0x7c396000 D:\program files (x86)\Java\jdk1.6.0_10\jre\bin\msvcr71.dll
0x6d8b0000 - 0x6db06000 D:\program files (x86)\Java\jdk1.6.0_10\jre\bin\client\jvm.dll
0x72c50000 - 0x72c82000 C:\Windows\system32\WINMM.dll
0x728d0000 - 0x7291c000 C:\Windows\system32\apphelp.dll
0x6d330000 - 0x6d338000 D:\program files (x86)\Java\jdk1.6.0_10\jre\bin\hpi.dll
0x76d70000 - 0x76d75000 C:\Windows\syswow64\PSAPI.DLL
0x6d860000 - 0x6d86c000 D:\program files (x86)\Java\jdk1.6.0_10\jre\bin\verify.dll
0x6d3d0000 - 0x6d3ef000 D:\program files (x86)\Java\jdk1.6.0_10\jre\bin\java.dll
0x6d8a0000 - 0x6d8af000 D:\program files (x86)\Java\jdk1.6.0_10\jre\bin\zip.dll
0x66c40000 - 0x66c61000 E:\children\textForRFID\JNativeCpp.dll
0x75540000 - 0x7569c000 C:\Windows\syswow64\OLE32.dll
0x76930000 - 0x769bf000 C:\Windows\syswow64\OLEAUT32.DLL
0x10000000 - 0x1002d000 D:\program files (x86)\Java\jdk1.6.0_10\bin\rfid.dll
0x02540000 - 0x02556000 D:\program files (x86)\Java\jdk1.6.0_10\bin\cpl.dll
0x04a50000 - 0x04a6c000 D:\program files (x86)\Java\jdk1.6.0_10\bin\rfidtx.dll
0x76e20000 - 0x76fbd000 C:\Windows\syswow64\SETUPAPI.dll
0x76410000 - 0x76437000 C:\Windows\syswow64\CFGMGR32.dll
0x76a40000 - 0x76a52000 C:\Windows\syswow64\DEVOBJ.dll
VM Arguments:
jvm_args: -Dfile.encoding=GBK
java_command: ecard.sys.javadll.EcardReaderImpl
Launcher Type: SUN_STANDARD
Environment Variables:
CLASSPATH=.;C:\Windows\System32;D:\program files (x86)\Java\jdk1.6.0_10\lib;D:\program files (x86)\Java\jdk1.6.0_10\lib\tools.jar;D:\program files (x86)\Java\jdk1.6.0_10\lib\dt.jar
PATH=D:/program files (x86)/Java/jdk1.6.0_10/bin/../jre/bin/client;D:/program files (x86)/Java/jdk1.6.0_10/bin/../jre/bin;D:/program files (x86)/Java/jdk1.6.0_10/bin/../jre/lib/i386;D:\program files (x86)\Java\jdk1.6.0_10\bin;D:\program files (x86)\Java\jdk1.6.0_10\jre\bin;D:\Program Files (x86)\MySQL\MySQL Server 5.0\bin;D:\program files (x86)\Apache Software Foundation\Tomcat 6.0\bin;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;D:\Program Files (x86)\Subversion\bin;d:\Program Files (x86)\Subversion\bin;C:\Windows/system32;C:\Windows;C:\Windows/System32/Wbem;D:\software\ToroiseSVN\bin;E:\workspace\JavaDllC++\nativeCode\Debug;D:\program files (x86)\eclipse - android\sdk\platforms;D:\program files (x86)\eclipse - android\sdk\platform-tools;D:\program files (x86)\eclipse;
USERNAME=BCIT-yf2
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 58 Stepping 9, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows NT 6.1 Build 7601 Service Pack 1
CPU:total 4 (8 cores per cpu, 2 threads per core) family 6 model 10 stepping 9, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, ht
Memory: 4k page, physical 4069560k(2196012k free), swap 4194303k(4194303k free)
vm_info: Java HotSpot(TM) Client VM (11.0-b15) for windows-x86 JRE (1.6.0_10-rc2-b32), built on Sep 12 2008 00:52:11 by "java_re" with MS VC++ 7.1
time: Thu Nov 07 09:31:58 2013
elapsed time: 0 seconds rfid
[解决办法]
堆栈溢出可能是死循环导致的
[解决办法]
楼主哪里看出来的堆栈溢出
我看着怎么像是 度地址错误~