3 个解决方案
#1
package com;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.WString;
import com.sun.jna.ptr.LongByReference;
public class JnaTest1 {
public interface CEBX2Image extends Library {
//定义Dll文件中的方法
int C2I_GetDocumentCount(WString szFileName, LongByReference msgCode);
}
public static void main(String[] args) {
CEBX2Image cEBX2Image = (CEBX2Image) Native.loadLibrary("CEBX2Image", CEBX2Image.class);
NativeLong [] array = new NativeLong[1];
array[0]= new NativeLong(1);
long a = 1l;
WString filePath = new WString("F:\\Files\\B_01000047_001.cebx");
WString key = new WString("123456");
LongByReference lbr = new LongByReference();
cEBX2Image.C2I_GetDocumentCount(filePath, null);
}
}
DLL中C++源码:C2IAPI_(C2I_UINT) C2I_GetDocumentCount(LPC2IWSTR szFileName, C2I_InvokeCode* pMsgCode)
{
return CC2IDocEngine::GetDocumentCount(szFileName, pMsgCode);
}
程序运行后报如下错误
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x120082c0, pid=3980, tid=5288
#
# Java VM: Java HotSpot(TM) Client VM (11.2-b01 mixed mode windows-x86)
# Problematic frame:
# C [xerces-c_3_0.dll+0x82c0]
#
# An error report file with more information is saved as:
# D:\孙源\JnaTest\hs_err_pid3980.log
#
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.WString;
import com.sun.jna.ptr.LongByReference;
public class JnaTest1 {
public interface CEBX2Image extends Library {
//定义Dll文件中的方法
int C2I_GetDocumentCount(WString szFileName, LongByReference msgCode);
}
public static void main(String[] args) {
CEBX2Image cEBX2Image = (CEBX2Image) Native.loadLibrary("CEBX2Image", CEBX2Image.class);
NativeLong [] array = new NativeLong[1];
array[0]= new NativeLong(1);
long a = 1l;
WString filePath = new WString("F:\\Files\\B_01000047_001.cebx");
WString key = new WString("123456");
LongByReference lbr = new LongByReference();
cEBX2Image.C2I_GetDocumentCount(filePath, null);
}
}
DLL中C++源码:C2IAPI_(C2I_UINT) C2I_GetDocumentCount(LPC2IWSTR szFileName, C2I_InvokeCode* pMsgCode)
{
return CC2IDocEngine::GetDocumentCount(szFileName, pMsgCode);
}
程序运行后报如下错误
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x120082c0, pid=3980, tid=5288
#
# Java VM: Java HotSpot(TM) Client VM (11.2-b01 mixed mode windows-x86)
# Problematic frame:
# C [xerces-c_3_0.dll+0x82c0]
#
# An error report file with more information is saved as:
# D:\孙源\JnaTest\hs_err_pid3980.log
#
#2
这个是hs_err_pid3980.log错误日志信息,求高人看看是什么问题,个人觉得是C++参数和JAVA方法声明和调用中参数类型不一致造成的!
#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x120082c0, pid=3664, tid=4968
#
# Java VM: Java HotSpot(TM) Client VM (11.2-b01 mixed mode windows-x86)
# Problematic frame:
# C [xerces-c_3_0.dll+0x82c0]
#
# 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.
#
--------------- T H R E A D ---------------
Current thread (0x00847000): JavaThread "main" [_thread_in_native, id=4968, stack(0x008d0000,0x00920000)]
siginfo: ExceptionCode=0xc0000005, reading address 0x00000000
Registers:
EAX=0x0091f74c, EBX=0x00000000, ECX=0x00000000, EDX=0x00000070
ESP=0x0091f738, EBP=0x0091f7a0, ESI=0x0b842260, EDI=0x0b842318
EIP=0x120082c0, EFLAGS=0x00010206
Top of Stack: (sp=0x0091f738)
0x0091f738: 0b583baa 00000070 3d63174e 0b842260
0x0091f748: 00000004 0091f76c 0b6b484c ffffffff
0x0091f758: 0b4f236b 3d63176a 0b842160 00000001
0x0091f768: 0b842318 0091f794 0b6bafeb 00000000
0x0091f778: 0b4daedd 3d63178a 0b842160 0091f808
0x0091f788: 00000001 0b842260 368201ea 0091f7e4
0x0091f798: 0b6bb2db ffffffff 0affb0d0 0b4b3bde
0x0091f7a8: 00000000 3d6317ba 00847000 0091f920
Instructions: (pc=0x120082c0)
0x120082b0: 8b c6 5e c2 04 00 8b 54 24 04 8b 0d c4 bf 1b 12
0x120082c0: 8b 01 83 c2 08 52 ff 50 08 8b 0d c4 bf 1b 12 89
Stack: [0x008d0000,0x00920000], sp=0x0091f738, free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [xerces-c_3_0.dll+0x82c0]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.sun.jna.Function.invokeInt(I[Ljava/lang/Object;)I+0
j com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;+309
j com.sun.jna.Function.invoke(Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;+194
j com.sun.jna.Library$Handler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+344
j $Proxy0.C2I_GetDocumentCount(Lcom/sun/jna/WString;Lcom/sun/jna/NativeLong;)I+20
j com.JnaTest1.main([Ljava/lang/String;)V+66
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x0ab0b800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=4996, stack(0x0ad50000,0x0ada0000)]
0x0ab05400 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3240, stack(0x0ad00000,0x0ad50000)]
0x0aaff400 JavaThread "Attach Listener" daemon [_thread_blocked, id=5704, stack(0x0acb0000,0x0ad00000)]
0x0aafe400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=1788, stack(0x0ac60000,0x0acb0000)]
0x0aae9c00 JavaThread "Finalizer" daemon [_thread_blocked, id=5820, stack(0x0ac10000,0x0ac60000)]
0x0aae8400 JavaThread "Reference Handler" daemon [_thread_blocked, id=3724, stack(0x0abc0000,0x0ac10000)]
=>0x00847000 JavaThread "main" [_thread_in_native, id=4968, stack(0x008d0000,0x00920000)]
Other Threads:
0x0aae4c00 VMThread [stack: 0x0ab70000,0x0abc0000] [id=1380]
0x0ab0d400 WatcherThread [stack: 0x0ada0000,0x0adf0000] [id=5952]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 960K, used 594K [0x029d0000, 0x02ad0000, 0x02eb0000)
eden space 896K, 59% used [0x029d0000, 0x02a54a70, 0x02ab0000)
from space 64K, 100% used [0x02ac0000, 0x02ad0000, 0x02ad0000)
to space 64K, 0% used [0x02ab0000, 0x02ab0000, 0x02ac0000)
tenured generation total 4096K, used 197K [0x02eb0000, 0x032b0000, 0x069d0000)
the space 4096K, 4% used [0x02eb0000, 0x02ee16a0, 0x02ee1800, 0x032b0000)
compacting perm gen total 12288K, used 3361K [0x069d0000, 0x075d0000, 0x0a9d0000)
the space 12288K, 27% used [0x069d0000, 0x06d185b8, 0x06d18600, 0x075d0000)
No shared spaces configured.
Dynamic libraries:
0x00400000 - 0x00424000 D:\founder\jdk1.6\bin\javaw.exe
0x7c930000 - 0x7ca00000 E:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c92b000 E:\WINDOWS\system32\kernel32.dll
0x77f30000 - 0x77fdb000 E:\WINDOWS\system32\ADVAPI32.dll
0x77c20000 - 0x77cbf000 E:\WINDOWS\system32\RPCRT4.dll
0x76eb0000 - 0x76ec3000 E:\WINDOWS\system32\Secur32.dll
0x77e10000 - 0x77ea0000 E:\WINDOWS\system32\USER32.dll
0x77bd0000 - 0x77c18000 E:\WINDOWS\system32\GDI32.dll
0x76180000 - 0x7619d000 E:\WINDOWS\system32\IMM32.DLL
0x7f000000 - 0x7f009000 E:\WINDOWS\system32\LPK.DLL
0x74ae0000 - 0x74b45000 E:\WINDOWS\system32\USP10.dll
0x7c340000 - 0x7c396000 D:\founder\jdk1.6\jre\bin\msvcr71.dll
0x6d8b0000 - 0x6db06000 D:\founder\jdk1.6\jre\bin\client\jvm.dll
0x769e0000 - 0x76a0a000 E:\WINDOWS\system32\WINMM.dll
0x6d340000 - 0x6d348000 D:\founder\jdk1.6\jre\bin\hpi.dll
0x76ab0000 - 0x76abb000 E:\WINDOWS\system32\PSAPI.DLL
0x6d860000 - 0x6d86c000 D:\founder\jdk1.6\jre\bin\verify.dll
0x6d3e0000 - 0x6d3ff000 D:\founder\jdk1.6\jre\bin\java.dll
0x6d8a0000 - 0x6d8af000 D:\founder\jdk1.6\jre\bin\zip.dll
0x68000000 - 0x68035000 E:\WINDOWS\system32\rsaenh.dll
0x77b70000 - 0x77bca000 E:\WINDOWS\system32\msvcrt.dll
0x75870000 - 0x7592d000 E:\WINDOWS\system32\USERENV.dll
0x71ba0000 - 0x71bf7000 E:\WINDOWS\system32\netapi32.dll
0x6d6c0000 - 0x6d6d3000 D:\founder\jdk1.6\jre\bin\net.dll
0x71b60000 - 0x71b77000 E:\WINDOWS\system32\WS2_32.dll
0x71b50000 - 0x71b58000 E:\WINDOWS\system32\WS2HELP.dll
0x55600000 - 0x55635000 E:\Program Files\Microsoft Firewall Client 2004\FwcWsp.dll
0x775f0000 - 0x7767b000 E:\WINDOWS\system32\OLEAUT32.dll
0x774b0000 - 0x775e9000 E:\WINDOWS\system32\ole32.dll
0x71a80000 - 0x71ac0000 E:\WINDOWS\System32\mswsock.dll
0x76e30000 - 0x76e5b000 E:\WINDOWS\system32\DNSAPI.dll
0x76ed0000 - 0x76ed7000 E:\WINDOWS\System32\winrnr.dll
0x76e70000 - 0x76e9e000 E:\WINDOWS\system32\WLDAP32.dll
0x69660000 - 0x696b7000 E:\WINDOWS\system32\hnetcfg.dll
0x77eb0000 - 0x77f02000 E:\WINDOWS\system32\SHLWAPI.dll
0x77cd0000 - 0x77dd3000 E:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.3790.3959_x-ww_D8713E55\comctl32.dll
0x71a40000 - 0x71a48000 E:\WINDOWS\System32\wshtcpip.dll
0x76ee0000 - 0x76ee5000 E:\WINDOWS\system32\rasadhlp.dll
0x10000000 - 0x10052000 E:\Documents and Settings\Administrator\Local Settings\Temp\jna6656590331965838877.tmp
0x0b370000 - 0x0b4a4000 E:\WINDOWS\system32\CEBX2Image.dll
0x0b4b0000 - 0x0b75e000 E:\WINDOWS\system32\XEKrnl.dll
0x12000000 - 0x121e3000 E:\WINDOWS\system32\xerces-c_3_0.dll
0x76170000 - 0x76175000 E:\WINDOWS\system32\MSIMG32.dll
0x0b780000 - 0x0b7fb000 E:\WINDOWS\system32\MercProcessor.dll
0x4c620000 - 0x4c7c7000 E:\WINDOWS\WinSxS\x86_Microsoft.Windows.GdiPlus_6595b64144ccf1df_1.0.3790.3959_x-ww_8251BDDE\gdiplus.dll
VM Arguments:
jvm_args: -Xbootclasspath/a:F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\javaee.jar;F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\jsf-impl.jar;F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\jsf-api.jar;F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\jstl-1.2.jar
java_command: com.JnaTest1
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=D:\founder\jdk1.6
PATH=D:\founder\jdk1.6\bin;E:\WINDOWS\system32;E:\WINDOWS;E:\WINDOWS\System32\Wbem;E:\WINDOWS\system32\WindowsPowerShell\v1.0;E:\Program Files\Microsoft SQL Server\100\Tools\Binn\;E:\Program Files\Microsoft SQL Server\100\DTS\Binn\;E:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;E:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;E:\Program Files\Microsoft SQL Server\90\Tools\binn\
USERNAME=Administrator
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 10, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows Server 2003 family Build 3790 Service Pack 2
CPU:total 4 (4 cores per cpu, 1 threads per core) family 6 model 7 stepping 10, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3
Memory: 4k page, physical 2097151k(1154672k free), swap 4194303k(3318988k free)
vm_info: Java HotSpot(TM) Client VM (11.2-b01) for windows-x86 JRE (1.6.0_12-b04), built on Jan 17 2009 09:57:14 by "java_re" with MS VC++ 7.1
time: Wed Jun 29 14:24:42 2011
elapsed time: 0 seconds
#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x120082c0, pid=3664, tid=4968
#
# Java VM: Java HotSpot(TM) Client VM (11.2-b01 mixed mode windows-x86)
# Problematic frame:
# C [xerces-c_3_0.dll+0x82c0]
#
# 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.
#
--------------- T H R E A D ---------------
Current thread (0x00847000): JavaThread "main" [_thread_in_native, id=4968, stack(0x008d0000,0x00920000)]
siginfo: ExceptionCode=0xc0000005, reading address 0x00000000
Registers:
EAX=0x0091f74c, EBX=0x00000000, ECX=0x00000000, EDX=0x00000070
ESP=0x0091f738, EBP=0x0091f7a0, ESI=0x0b842260, EDI=0x0b842318
EIP=0x120082c0, EFLAGS=0x00010206
Top of Stack: (sp=0x0091f738)
0x0091f738: 0b583baa 00000070 3d63174e 0b842260
0x0091f748: 00000004 0091f76c 0b6b484c ffffffff
0x0091f758: 0b4f236b 3d63176a 0b842160 00000001
0x0091f768: 0b842318 0091f794 0b6bafeb 00000000
0x0091f778: 0b4daedd 3d63178a 0b842160 0091f808
0x0091f788: 00000001 0b842260 368201ea 0091f7e4
0x0091f798: 0b6bb2db ffffffff 0affb0d0 0b4b3bde
0x0091f7a8: 00000000 3d6317ba 00847000 0091f920
Instructions: (pc=0x120082c0)
0x120082b0: 8b c6 5e c2 04 00 8b 54 24 04 8b 0d c4 bf 1b 12
0x120082c0: 8b 01 83 c2 08 52 ff 50 08 8b 0d c4 bf 1b 12 89
Stack: [0x008d0000,0x00920000], sp=0x0091f738, free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [xerces-c_3_0.dll+0x82c0]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.sun.jna.Function.invokeInt(I[Ljava/lang/Object;)I+0
j com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;+309
j com.sun.jna.Function.invoke(Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;+194
j com.sun.jna.Library$Handler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+344
j $Proxy0.C2I_GetDocumentCount(Lcom/sun/jna/WString;Lcom/sun/jna/NativeLong;)I+20
j com.JnaTest1.main([Ljava/lang/String;)V+66
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x0ab0b800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=4996, stack(0x0ad50000,0x0ada0000)]
0x0ab05400 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3240, stack(0x0ad00000,0x0ad50000)]
0x0aaff400 JavaThread "Attach Listener" daemon [_thread_blocked, id=5704, stack(0x0acb0000,0x0ad00000)]
0x0aafe400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=1788, stack(0x0ac60000,0x0acb0000)]
0x0aae9c00 JavaThread "Finalizer" daemon [_thread_blocked, id=5820, stack(0x0ac10000,0x0ac60000)]
0x0aae8400 JavaThread "Reference Handler" daemon [_thread_blocked, id=3724, stack(0x0abc0000,0x0ac10000)]
=>0x00847000 JavaThread "main" [_thread_in_native, id=4968, stack(0x008d0000,0x00920000)]
Other Threads:
0x0aae4c00 VMThread [stack: 0x0ab70000,0x0abc0000] [id=1380]
0x0ab0d400 WatcherThread [stack: 0x0ada0000,0x0adf0000] [id=5952]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 960K, used 594K [0x029d0000, 0x02ad0000, 0x02eb0000)
eden space 896K, 59% used [0x029d0000, 0x02a54a70, 0x02ab0000)
from space 64K, 100% used [0x02ac0000, 0x02ad0000, 0x02ad0000)
to space 64K, 0% used [0x02ab0000, 0x02ab0000, 0x02ac0000)
tenured generation total 4096K, used 197K [0x02eb0000, 0x032b0000, 0x069d0000)
the space 4096K, 4% used [0x02eb0000, 0x02ee16a0, 0x02ee1800, 0x032b0000)
compacting perm gen total 12288K, used 3361K [0x069d0000, 0x075d0000, 0x0a9d0000)
the space 12288K, 27% used [0x069d0000, 0x06d185b8, 0x06d18600, 0x075d0000)
No shared spaces configured.
Dynamic libraries:
0x00400000 - 0x00424000 D:\founder\jdk1.6\bin\javaw.exe
0x7c930000 - 0x7ca00000 E:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c92b000 E:\WINDOWS\system32\kernel32.dll
0x77f30000 - 0x77fdb000 E:\WINDOWS\system32\ADVAPI32.dll
0x77c20000 - 0x77cbf000 E:\WINDOWS\system32\RPCRT4.dll
0x76eb0000 - 0x76ec3000 E:\WINDOWS\system32\Secur32.dll
0x77e10000 - 0x77ea0000 E:\WINDOWS\system32\USER32.dll
0x77bd0000 - 0x77c18000 E:\WINDOWS\system32\GDI32.dll
0x76180000 - 0x7619d000 E:\WINDOWS\system32\IMM32.DLL
0x7f000000 - 0x7f009000 E:\WINDOWS\system32\LPK.DLL
0x74ae0000 - 0x74b45000 E:\WINDOWS\system32\USP10.dll
0x7c340000 - 0x7c396000 D:\founder\jdk1.6\jre\bin\msvcr71.dll
0x6d8b0000 - 0x6db06000 D:\founder\jdk1.6\jre\bin\client\jvm.dll
0x769e0000 - 0x76a0a000 E:\WINDOWS\system32\WINMM.dll
0x6d340000 - 0x6d348000 D:\founder\jdk1.6\jre\bin\hpi.dll
0x76ab0000 - 0x76abb000 E:\WINDOWS\system32\PSAPI.DLL
0x6d860000 - 0x6d86c000 D:\founder\jdk1.6\jre\bin\verify.dll
0x6d3e0000 - 0x6d3ff000 D:\founder\jdk1.6\jre\bin\java.dll
0x6d8a0000 - 0x6d8af000 D:\founder\jdk1.6\jre\bin\zip.dll
0x68000000 - 0x68035000 E:\WINDOWS\system32\rsaenh.dll
0x77b70000 - 0x77bca000 E:\WINDOWS\system32\msvcrt.dll
0x75870000 - 0x7592d000 E:\WINDOWS\system32\USERENV.dll
0x71ba0000 - 0x71bf7000 E:\WINDOWS\system32\netapi32.dll
0x6d6c0000 - 0x6d6d3000 D:\founder\jdk1.6\jre\bin\net.dll
0x71b60000 - 0x71b77000 E:\WINDOWS\system32\WS2_32.dll
0x71b50000 - 0x71b58000 E:\WINDOWS\system32\WS2HELP.dll
0x55600000 - 0x55635000 E:\Program Files\Microsoft Firewall Client 2004\FwcWsp.dll
0x775f0000 - 0x7767b000 E:\WINDOWS\system32\OLEAUT32.dll
0x774b0000 - 0x775e9000 E:\WINDOWS\system32\ole32.dll
0x71a80000 - 0x71ac0000 E:\WINDOWS\System32\mswsock.dll
0x76e30000 - 0x76e5b000 E:\WINDOWS\system32\DNSAPI.dll
0x76ed0000 - 0x76ed7000 E:\WINDOWS\System32\winrnr.dll
0x76e70000 - 0x76e9e000 E:\WINDOWS\system32\WLDAP32.dll
0x69660000 - 0x696b7000 E:\WINDOWS\system32\hnetcfg.dll
0x77eb0000 - 0x77f02000 E:\WINDOWS\system32\SHLWAPI.dll
0x77cd0000 - 0x77dd3000 E:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.3790.3959_x-ww_D8713E55\comctl32.dll
0x71a40000 - 0x71a48000 E:\WINDOWS\System32\wshtcpip.dll
0x76ee0000 - 0x76ee5000 E:\WINDOWS\system32\rasadhlp.dll
0x10000000 - 0x10052000 E:\Documents and Settings\Administrator\Local Settings\Temp\jna6656590331965838877.tmp
0x0b370000 - 0x0b4a4000 E:\WINDOWS\system32\CEBX2Image.dll
0x0b4b0000 - 0x0b75e000 E:\WINDOWS\system32\XEKrnl.dll
0x12000000 - 0x121e3000 E:\WINDOWS\system32\xerces-c_3_0.dll
0x76170000 - 0x76175000 E:\WINDOWS\system32\MSIMG32.dll
0x0b780000 - 0x0b7fb000 E:\WINDOWS\system32\MercProcessor.dll
0x4c620000 - 0x4c7c7000 E:\WINDOWS\WinSxS\x86_Microsoft.Windows.GdiPlus_6595b64144ccf1df_1.0.3790.3959_x-ww_8251BDDE\gdiplus.dll
VM Arguments:
jvm_args: -Xbootclasspath/a:F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\javaee.jar;F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\jsf-impl.jar;F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\jsf-api.jar;F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\jstl-1.2.jar
java_command: com.JnaTest1
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=D:\founder\jdk1.6
PATH=D:\founder\jdk1.6\bin;E:\WINDOWS\system32;E:\WINDOWS;E:\WINDOWS\System32\Wbem;E:\WINDOWS\system32\WindowsPowerShell\v1.0;E:\Program Files\Microsoft SQL Server\100\Tools\Binn\;E:\Program Files\Microsoft SQL Server\100\DTS\Binn\;E:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;E:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;E:\Program Files\Microsoft SQL Server\90\Tools\binn\
USERNAME=Administrator
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 10, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows Server 2003 family Build 3790 Service Pack 2
CPU:total 4 (4 cores per cpu, 1 threads per core) family 6 model 7 stepping 10, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3
Memory: 4k page, physical 2097151k(1154672k free), swap 4194303k(3318988k free)
vm_info: Java HotSpot(TM) Client VM (11.2-b01) for windows-x86 JRE (1.6.0_12-b04), built on Jan 17 2009 09:57:14 by "java_re" with MS VC++ 7.1
time: Wed Jun 29 14:24:42 2011
elapsed time: 0 seconds
#3
我也遇到这问题,未解决。求高人解决。
c++代码:
#define MYLIBAPI extern "C" __declspec(dllexport)
MYLIBAPI int sayStr(string strBuf,int Ito);
int sayStr(string strBuf,int Ito)
{
Ito = 2;
string str = "abcde";
strBuf = str.c_str();
return 0;
}
java代码:
public class TestDll1Service {
public interface TestDll1 extends Library {
TestDll1 INSTANCE = (TestDll1)Native.loadLibrary("TestDll1",TestDll1.class);
public int sayStr(char* szBufv,int Ito);
}
public static void main(String[] args) {
byte sz[] = new byte[8];
int Ito = 0;
int zdps = TestDll1.INSTANCE.sayStr(sz,Ito);
System.out.println("ito:" + Ito);
}
}
这段代码的意图是想从C++的Ito:2传给java中的Ito ,结果java中的Ito还是为0;即输出参数还是0
错误提示:
An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=4876, tid=2164
#
# Java VM: Java HotSpot(TM) Client VM (11.0-b15 mixed mode windows-x86)
# Problematic frame:
# C 0x00000000
#......
c++代码:
#define MYLIBAPI extern "C" __declspec(dllexport)
MYLIBAPI int sayStr(string strBuf,int Ito);
int sayStr(string strBuf,int Ito)
{
Ito = 2;
string str = "abcde";
strBuf = str.c_str();
return 0;
}
java代码:
public class TestDll1Service {
public interface TestDll1 extends Library {
TestDll1 INSTANCE = (TestDll1)Native.loadLibrary("TestDll1",TestDll1.class);
public int sayStr(char* szBufv,int Ito);
}
public static void main(String[] args) {
byte sz[] = new byte[8];
int Ito = 0;
int zdps = TestDll1.INSTANCE.sayStr(sz,Ito);
System.out.println("ito:" + Ito);
}
}
这段代码的意图是想从C++的Ito:2传给java中的Ito ,结果java中的Ito还是为0;即输出参数还是0
错误提示:
An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=4876, tid=2164
#
# Java VM: Java HotSpot(TM) Client VM (11.0-b15 mixed mode windows-x86)
# Problematic frame:
# C 0x00000000
#......
#1
package com;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.WString;
import com.sun.jna.ptr.LongByReference;
public class JnaTest1 {
public interface CEBX2Image extends Library {
//定义Dll文件中的方法
int C2I_GetDocumentCount(WString szFileName, LongByReference msgCode);
}
public static void main(String[] args) {
CEBX2Image cEBX2Image = (CEBX2Image) Native.loadLibrary("CEBX2Image", CEBX2Image.class);
NativeLong [] array = new NativeLong[1];
array[0]= new NativeLong(1);
long a = 1l;
WString filePath = new WString("F:\\Files\\B_01000047_001.cebx");
WString key = new WString("123456");
LongByReference lbr = new LongByReference();
cEBX2Image.C2I_GetDocumentCount(filePath, null);
}
}
DLL中C++源码:C2IAPI_(C2I_UINT) C2I_GetDocumentCount(LPC2IWSTR szFileName, C2I_InvokeCode* pMsgCode)
{
return CC2IDocEngine::GetDocumentCount(szFileName, pMsgCode);
}
程序运行后报如下错误
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x120082c0, pid=3980, tid=5288
#
# Java VM: Java HotSpot(TM) Client VM (11.2-b01 mixed mode windows-x86)
# Problematic frame:
# C [xerces-c_3_0.dll+0x82c0]
#
# An error report file with more information is saved as:
# D:\孙源\JnaTest\hs_err_pid3980.log
#
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.WString;
import com.sun.jna.ptr.LongByReference;
public class JnaTest1 {
public interface CEBX2Image extends Library {
//定义Dll文件中的方法
int C2I_GetDocumentCount(WString szFileName, LongByReference msgCode);
}
public static void main(String[] args) {
CEBX2Image cEBX2Image = (CEBX2Image) Native.loadLibrary("CEBX2Image", CEBX2Image.class);
NativeLong [] array = new NativeLong[1];
array[0]= new NativeLong(1);
long a = 1l;
WString filePath = new WString("F:\\Files\\B_01000047_001.cebx");
WString key = new WString("123456");
LongByReference lbr = new LongByReference();
cEBX2Image.C2I_GetDocumentCount(filePath, null);
}
}
DLL中C++源码:C2IAPI_(C2I_UINT) C2I_GetDocumentCount(LPC2IWSTR szFileName, C2I_InvokeCode* pMsgCode)
{
return CC2IDocEngine::GetDocumentCount(szFileName, pMsgCode);
}
程序运行后报如下错误
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x120082c0, pid=3980, tid=5288
#
# Java VM: Java HotSpot(TM) Client VM (11.2-b01 mixed mode windows-x86)
# Problematic frame:
# C [xerces-c_3_0.dll+0x82c0]
#
# An error report file with more information is saved as:
# D:\孙源\JnaTest\hs_err_pid3980.log
#
#2
这个是hs_err_pid3980.log错误日志信息,求高人看看是什么问题,个人觉得是C++参数和JAVA方法声明和调用中参数类型不一致造成的!
#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x120082c0, pid=3664, tid=4968
#
# Java VM: Java HotSpot(TM) Client VM (11.2-b01 mixed mode windows-x86)
# Problematic frame:
# C [xerces-c_3_0.dll+0x82c0]
#
# 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.
#
--------------- T H R E A D ---------------
Current thread (0x00847000): JavaThread "main" [_thread_in_native, id=4968, stack(0x008d0000,0x00920000)]
siginfo: ExceptionCode=0xc0000005, reading address 0x00000000
Registers:
EAX=0x0091f74c, EBX=0x00000000, ECX=0x00000000, EDX=0x00000070
ESP=0x0091f738, EBP=0x0091f7a0, ESI=0x0b842260, EDI=0x0b842318
EIP=0x120082c0, EFLAGS=0x00010206
Top of Stack: (sp=0x0091f738)
0x0091f738: 0b583baa 00000070 3d63174e 0b842260
0x0091f748: 00000004 0091f76c 0b6b484c ffffffff
0x0091f758: 0b4f236b 3d63176a 0b842160 00000001
0x0091f768: 0b842318 0091f794 0b6bafeb 00000000
0x0091f778: 0b4daedd 3d63178a 0b842160 0091f808
0x0091f788: 00000001 0b842260 368201ea 0091f7e4
0x0091f798: 0b6bb2db ffffffff 0affb0d0 0b4b3bde
0x0091f7a8: 00000000 3d6317ba 00847000 0091f920
Instructions: (pc=0x120082c0)
0x120082b0: 8b c6 5e c2 04 00 8b 54 24 04 8b 0d c4 bf 1b 12
0x120082c0: 8b 01 83 c2 08 52 ff 50 08 8b 0d c4 bf 1b 12 89
Stack: [0x008d0000,0x00920000], sp=0x0091f738, free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [xerces-c_3_0.dll+0x82c0]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.sun.jna.Function.invokeInt(I[Ljava/lang/Object;)I+0
j com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;+309
j com.sun.jna.Function.invoke(Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;+194
j com.sun.jna.Library$Handler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+344
j $Proxy0.C2I_GetDocumentCount(Lcom/sun/jna/WString;Lcom/sun/jna/NativeLong;)I+20
j com.JnaTest1.main([Ljava/lang/String;)V+66
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x0ab0b800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=4996, stack(0x0ad50000,0x0ada0000)]
0x0ab05400 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3240, stack(0x0ad00000,0x0ad50000)]
0x0aaff400 JavaThread "Attach Listener" daemon [_thread_blocked, id=5704, stack(0x0acb0000,0x0ad00000)]
0x0aafe400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=1788, stack(0x0ac60000,0x0acb0000)]
0x0aae9c00 JavaThread "Finalizer" daemon [_thread_blocked, id=5820, stack(0x0ac10000,0x0ac60000)]
0x0aae8400 JavaThread "Reference Handler" daemon [_thread_blocked, id=3724, stack(0x0abc0000,0x0ac10000)]
=>0x00847000 JavaThread "main" [_thread_in_native, id=4968, stack(0x008d0000,0x00920000)]
Other Threads:
0x0aae4c00 VMThread [stack: 0x0ab70000,0x0abc0000] [id=1380]
0x0ab0d400 WatcherThread [stack: 0x0ada0000,0x0adf0000] [id=5952]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 960K, used 594K [0x029d0000, 0x02ad0000, 0x02eb0000)
eden space 896K, 59% used [0x029d0000, 0x02a54a70, 0x02ab0000)
from space 64K, 100% used [0x02ac0000, 0x02ad0000, 0x02ad0000)
to space 64K, 0% used [0x02ab0000, 0x02ab0000, 0x02ac0000)
tenured generation total 4096K, used 197K [0x02eb0000, 0x032b0000, 0x069d0000)
the space 4096K, 4% used [0x02eb0000, 0x02ee16a0, 0x02ee1800, 0x032b0000)
compacting perm gen total 12288K, used 3361K [0x069d0000, 0x075d0000, 0x0a9d0000)
the space 12288K, 27% used [0x069d0000, 0x06d185b8, 0x06d18600, 0x075d0000)
No shared spaces configured.
Dynamic libraries:
0x00400000 - 0x00424000 D:\founder\jdk1.6\bin\javaw.exe
0x7c930000 - 0x7ca00000 E:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c92b000 E:\WINDOWS\system32\kernel32.dll
0x77f30000 - 0x77fdb000 E:\WINDOWS\system32\ADVAPI32.dll
0x77c20000 - 0x77cbf000 E:\WINDOWS\system32\RPCRT4.dll
0x76eb0000 - 0x76ec3000 E:\WINDOWS\system32\Secur32.dll
0x77e10000 - 0x77ea0000 E:\WINDOWS\system32\USER32.dll
0x77bd0000 - 0x77c18000 E:\WINDOWS\system32\GDI32.dll
0x76180000 - 0x7619d000 E:\WINDOWS\system32\IMM32.DLL
0x7f000000 - 0x7f009000 E:\WINDOWS\system32\LPK.DLL
0x74ae0000 - 0x74b45000 E:\WINDOWS\system32\USP10.dll
0x7c340000 - 0x7c396000 D:\founder\jdk1.6\jre\bin\msvcr71.dll
0x6d8b0000 - 0x6db06000 D:\founder\jdk1.6\jre\bin\client\jvm.dll
0x769e0000 - 0x76a0a000 E:\WINDOWS\system32\WINMM.dll
0x6d340000 - 0x6d348000 D:\founder\jdk1.6\jre\bin\hpi.dll
0x76ab0000 - 0x76abb000 E:\WINDOWS\system32\PSAPI.DLL
0x6d860000 - 0x6d86c000 D:\founder\jdk1.6\jre\bin\verify.dll
0x6d3e0000 - 0x6d3ff000 D:\founder\jdk1.6\jre\bin\java.dll
0x6d8a0000 - 0x6d8af000 D:\founder\jdk1.6\jre\bin\zip.dll
0x68000000 - 0x68035000 E:\WINDOWS\system32\rsaenh.dll
0x77b70000 - 0x77bca000 E:\WINDOWS\system32\msvcrt.dll
0x75870000 - 0x7592d000 E:\WINDOWS\system32\USERENV.dll
0x71ba0000 - 0x71bf7000 E:\WINDOWS\system32\netapi32.dll
0x6d6c0000 - 0x6d6d3000 D:\founder\jdk1.6\jre\bin\net.dll
0x71b60000 - 0x71b77000 E:\WINDOWS\system32\WS2_32.dll
0x71b50000 - 0x71b58000 E:\WINDOWS\system32\WS2HELP.dll
0x55600000 - 0x55635000 E:\Program Files\Microsoft Firewall Client 2004\FwcWsp.dll
0x775f0000 - 0x7767b000 E:\WINDOWS\system32\OLEAUT32.dll
0x774b0000 - 0x775e9000 E:\WINDOWS\system32\ole32.dll
0x71a80000 - 0x71ac0000 E:\WINDOWS\System32\mswsock.dll
0x76e30000 - 0x76e5b000 E:\WINDOWS\system32\DNSAPI.dll
0x76ed0000 - 0x76ed7000 E:\WINDOWS\System32\winrnr.dll
0x76e70000 - 0x76e9e000 E:\WINDOWS\system32\WLDAP32.dll
0x69660000 - 0x696b7000 E:\WINDOWS\system32\hnetcfg.dll
0x77eb0000 - 0x77f02000 E:\WINDOWS\system32\SHLWAPI.dll
0x77cd0000 - 0x77dd3000 E:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.3790.3959_x-ww_D8713E55\comctl32.dll
0x71a40000 - 0x71a48000 E:\WINDOWS\System32\wshtcpip.dll
0x76ee0000 - 0x76ee5000 E:\WINDOWS\system32\rasadhlp.dll
0x10000000 - 0x10052000 E:\Documents and Settings\Administrator\Local Settings\Temp\jna6656590331965838877.tmp
0x0b370000 - 0x0b4a4000 E:\WINDOWS\system32\CEBX2Image.dll
0x0b4b0000 - 0x0b75e000 E:\WINDOWS\system32\XEKrnl.dll
0x12000000 - 0x121e3000 E:\WINDOWS\system32\xerces-c_3_0.dll
0x76170000 - 0x76175000 E:\WINDOWS\system32\MSIMG32.dll
0x0b780000 - 0x0b7fb000 E:\WINDOWS\system32\MercProcessor.dll
0x4c620000 - 0x4c7c7000 E:\WINDOWS\WinSxS\x86_Microsoft.Windows.GdiPlus_6595b64144ccf1df_1.0.3790.3959_x-ww_8251BDDE\gdiplus.dll
VM Arguments:
jvm_args: -Xbootclasspath/a:F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\javaee.jar;F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\jsf-impl.jar;F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\jsf-api.jar;F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\jstl-1.2.jar
java_command: com.JnaTest1
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=D:\founder\jdk1.6
PATH=D:\founder\jdk1.6\bin;E:\WINDOWS\system32;E:\WINDOWS;E:\WINDOWS\System32\Wbem;E:\WINDOWS\system32\WindowsPowerShell\v1.0;E:\Program Files\Microsoft SQL Server\100\Tools\Binn\;E:\Program Files\Microsoft SQL Server\100\DTS\Binn\;E:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;E:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;E:\Program Files\Microsoft SQL Server\90\Tools\binn\
USERNAME=Administrator
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 10, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows Server 2003 family Build 3790 Service Pack 2
CPU:total 4 (4 cores per cpu, 1 threads per core) family 6 model 7 stepping 10, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3
Memory: 4k page, physical 2097151k(1154672k free), swap 4194303k(3318988k free)
vm_info: Java HotSpot(TM) Client VM (11.2-b01) for windows-x86 JRE (1.6.0_12-b04), built on Jan 17 2009 09:57:14 by "java_re" with MS VC++ 7.1
time: Wed Jun 29 14:24:42 2011
elapsed time: 0 seconds
#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x120082c0, pid=3664, tid=4968
#
# Java VM: Java HotSpot(TM) Client VM (11.2-b01 mixed mode windows-x86)
# Problematic frame:
# C [xerces-c_3_0.dll+0x82c0]
#
# 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.
#
--------------- T H R E A D ---------------
Current thread (0x00847000): JavaThread "main" [_thread_in_native, id=4968, stack(0x008d0000,0x00920000)]
siginfo: ExceptionCode=0xc0000005, reading address 0x00000000
Registers:
EAX=0x0091f74c, EBX=0x00000000, ECX=0x00000000, EDX=0x00000070
ESP=0x0091f738, EBP=0x0091f7a0, ESI=0x0b842260, EDI=0x0b842318
EIP=0x120082c0, EFLAGS=0x00010206
Top of Stack: (sp=0x0091f738)
0x0091f738: 0b583baa 00000070 3d63174e 0b842260
0x0091f748: 00000004 0091f76c 0b6b484c ffffffff
0x0091f758: 0b4f236b 3d63176a 0b842160 00000001
0x0091f768: 0b842318 0091f794 0b6bafeb 00000000
0x0091f778: 0b4daedd 3d63178a 0b842160 0091f808
0x0091f788: 00000001 0b842260 368201ea 0091f7e4
0x0091f798: 0b6bb2db ffffffff 0affb0d0 0b4b3bde
0x0091f7a8: 00000000 3d6317ba 00847000 0091f920
Instructions: (pc=0x120082c0)
0x120082b0: 8b c6 5e c2 04 00 8b 54 24 04 8b 0d c4 bf 1b 12
0x120082c0: 8b 01 83 c2 08 52 ff 50 08 8b 0d c4 bf 1b 12 89
Stack: [0x008d0000,0x00920000], sp=0x0091f738, free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [xerces-c_3_0.dll+0x82c0]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.sun.jna.Function.invokeInt(I[Ljava/lang/Object;)I+0
j com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;+309
j com.sun.jna.Function.invoke(Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;+194
j com.sun.jna.Library$Handler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;+344
j $Proxy0.C2I_GetDocumentCount(Lcom/sun/jna/WString;Lcom/sun/jna/NativeLong;)I+20
j com.JnaTest1.main([Ljava/lang/String;)V+66
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x0ab0b800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=4996, stack(0x0ad50000,0x0ada0000)]
0x0ab05400 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3240, stack(0x0ad00000,0x0ad50000)]
0x0aaff400 JavaThread "Attach Listener" daemon [_thread_blocked, id=5704, stack(0x0acb0000,0x0ad00000)]
0x0aafe400 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=1788, stack(0x0ac60000,0x0acb0000)]
0x0aae9c00 JavaThread "Finalizer" daemon [_thread_blocked, id=5820, stack(0x0ac10000,0x0ac60000)]
0x0aae8400 JavaThread "Reference Handler" daemon [_thread_blocked, id=3724, stack(0x0abc0000,0x0ac10000)]
=>0x00847000 JavaThread "main" [_thread_in_native, id=4968, stack(0x008d0000,0x00920000)]
Other Threads:
0x0aae4c00 VMThread [stack: 0x0ab70000,0x0abc0000] [id=1380]
0x0ab0d400 WatcherThread [stack: 0x0ada0000,0x0adf0000] [id=5952]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 960K, used 594K [0x029d0000, 0x02ad0000, 0x02eb0000)
eden space 896K, 59% used [0x029d0000, 0x02a54a70, 0x02ab0000)
from space 64K, 100% used [0x02ac0000, 0x02ad0000, 0x02ad0000)
to space 64K, 0% used [0x02ab0000, 0x02ab0000, 0x02ac0000)
tenured generation total 4096K, used 197K [0x02eb0000, 0x032b0000, 0x069d0000)
the space 4096K, 4% used [0x02eb0000, 0x02ee16a0, 0x02ee1800, 0x032b0000)
compacting perm gen total 12288K, used 3361K [0x069d0000, 0x075d0000, 0x0a9d0000)
the space 12288K, 27% used [0x069d0000, 0x06d185b8, 0x06d18600, 0x075d0000)
No shared spaces configured.
Dynamic libraries:
0x00400000 - 0x00424000 D:\founder\jdk1.6\bin\javaw.exe
0x7c930000 - 0x7ca00000 E:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c92b000 E:\WINDOWS\system32\kernel32.dll
0x77f30000 - 0x77fdb000 E:\WINDOWS\system32\ADVAPI32.dll
0x77c20000 - 0x77cbf000 E:\WINDOWS\system32\RPCRT4.dll
0x76eb0000 - 0x76ec3000 E:\WINDOWS\system32\Secur32.dll
0x77e10000 - 0x77ea0000 E:\WINDOWS\system32\USER32.dll
0x77bd0000 - 0x77c18000 E:\WINDOWS\system32\GDI32.dll
0x76180000 - 0x7619d000 E:\WINDOWS\system32\IMM32.DLL
0x7f000000 - 0x7f009000 E:\WINDOWS\system32\LPK.DLL
0x74ae0000 - 0x74b45000 E:\WINDOWS\system32\USP10.dll
0x7c340000 - 0x7c396000 D:\founder\jdk1.6\jre\bin\msvcr71.dll
0x6d8b0000 - 0x6db06000 D:\founder\jdk1.6\jre\bin\client\jvm.dll
0x769e0000 - 0x76a0a000 E:\WINDOWS\system32\WINMM.dll
0x6d340000 - 0x6d348000 D:\founder\jdk1.6\jre\bin\hpi.dll
0x76ab0000 - 0x76abb000 E:\WINDOWS\system32\PSAPI.DLL
0x6d860000 - 0x6d86c000 D:\founder\jdk1.6\jre\bin\verify.dll
0x6d3e0000 - 0x6d3ff000 D:\founder\jdk1.6\jre\bin\java.dll
0x6d8a0000 - 0x6d8af000 D:\founder\jdk1.6\jre\bin\zip.dll
0x68000000 - 0x68035000 E:\WINDOWS\system32\rsaenh.dll
0x77b70000 - 0x77bca000 E:\WINDOWS\system32\msvcrt.dll
0x75870000 - 0x7592d000 E:\WINDOWS\system32\USERENV.dll
0x71ba0000 - 0x71bf7000 E:\WINDOWS\system32\netapi32.dll
0x6d6c0000 - 0x6d6d3000 D:\founder\jdk1.6\jre\bin\net.dll
0x71b60000 - 0x71b77000 E:\WINDOWS\system32\WS2_32.dll
0x71b50000 - 0x71b58000 E:\WINDOWS\system32\WS2HELP.dll
0x55600000 - 0x55635000 E:\Program Files\Microsoft Firewall Client 2004\FwcWsp.dll
0x775f0000 - 0x7767b000 E:\WINDOWS\system32\OLEAUT32.dll
0x774b0000 - 0x775e9000 E:\WINDOWS\system32\ole32.dll
0x71a80000 - 0x71ac0000 E:\WINDOWS\System32\mswsock.dll
0x76e30000 - 0x76e5b000 E:\WINDOWS\system32\DNSAPI.dll
0x76ed0000 - 0x76ed7000 E:\WINDOWS\System32\winrnr.dll
0x76e70000 - 0x76e9e000 E:\WINDOWS\system32\WLDAP32.dll
0x69660000 - 0x696b7000 E:\WINDOWS\system32\hnetcfg.dll
0x77eb0000 - 0x77f02000 E:\WINDOWS\system32\SHLWAPI.dll
0x77cd0000 - 0x77dd3000 E:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.3790.3959_x-ww_D8713E55\comctl32.dll
0x71a40000 - 0x71a48000 E:\WINDOWS\System32\wshtcpip.dll
0x76ee0000 - 0x76ee5000 E:\WINDOWS\system32\rasadhlp.dll
0x10000000 - 0x10052000 E:\Documents and Settings\Administrator\Local Settings\Temp\jna6656590331965838877.tmp
0x0b370000 - 0x0b4a4000 E:\WINDOWS\system32\CEBX2Image.dll
0x0b4b0000 - 0x0b75e000 E:\WINDOWS\system32\XEKrnl.dll
0x12000000 - 0x121e3000 E:\WINDOWS\system32\xerces-c_3_0.dll
0x76170000 - 0x76175000 E:\WINDOWS\system32\MSIMG32.dll
0x0b780000 - 0x0b7fb000 E:\WINDOWS\system32\MercProcessor.dll
0x4c620000 - 0x4c7c7000 E:\WINDOWS\WinSxS\x86_Microsoft.Windows.GdiPlus_6595b64144ccf1df_1.0.3790.3959_x-ww_8251BDDE\gdiplus.dll
VM Arguments:
jvm_args: -Xbootclasspath/a:F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\javaee.jar;F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\jsf-impl.jar;F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\jsf-api.jar;F:\MyEclipse\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.5.0.zmyeclipse650200806\data\libraryset\EE_5\jstl-1.2.jar
java_command: com.JnaTest1
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=D:\founder\jdk1.6
PATH=D:\founder\jdk1.6\bin;E:\WINDOWS\system32;E:\WINDOWS;E:\WINDOWS\System32\Wbem;E:\WINDOWS\system32\WindowsPowerShell\v1.0;E:\Program Files\Microsoft SQL Server\100\Tools\Binn\;E:\Program Files\Microsoft SQL Server\100\DTS\Binn\;E:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;E:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;E:\Program Files\Microsoft SQL Server\90\Tools\binn\
USERNAME=Administrator
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 10, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows Server 2003 family Build 3790 Service Pack 2
CPU:total 4 (4 cores per cpu, 1 threads per core) family 6 model 7 stepping 10, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3
Memory: 4k page, physical 2097151k(1154672k free), swap 4194303k(3318988k free)
vm_info: Java HotSpot(TM) Client VM (11.2-b01) for windows-x86 JRE (1.6.0_12-b04), built on Jan 17 2009 09:57:14 by "java_re" with MS VC++ 7.1
time: Wed Jun 29 14:24:42 2011
elapsed time: 0 seconds
#3
我也遇到这问题,未解决。求高人解决。
c++代码:
#define MYLIBAPI extern "C" __declspec(dllexport)
MYLIBAPI int sayStr(string strBuf,int Ito);
int sayStr(string strBuf,int Ito)
{
Ito = 2;
string str = "abcde";
strBuf = str.c_str();
return 0;
}
java代码:
public class TestDll1Service {
public interface TestDll1 extends Library {
TestDll1 INSTANCE = (TestDll1)Native.loadLibrary("TestDll1",TestDll1.class);
public int sayStr(char* szBufv,int Ito);
}
public static void main(String[] args) {
byte sz[] = new byte[8];
int Ito = 0;
int zdps = TestDll1.INSTANCE.sayStr(sz,Ito);
System.out.println("ito:" + Ito);
}
}
这段代码的意图是想从C++的Ito:2传给java中的Ito ,结果java中的Ito还是为0;即输出参数还是0
错误提示:
An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=4876, tid=2164
#
# Java VM: Java HotSpot(TM) Client VM (11.0-b15 mixed mode windows-x86)
# Problematic frame:
# C 0x00000000
#......
c++代码:
#define MYLIBAPI extern "C" __declspec(dllexport)
MYLIBAPI int sayStr(string strBuf,int Ito);
int sayStr(string strBuf,int Ito)
{
Ito = 2;
string str = "abcde";
strBuf = str.c_str();
return 0;
}
java代码:
public class TestDll1Service {
public interface TestDll1 extends Library {
TestDll1 INSTANCE = (TestDll1)Native.loadLibrary("TestDll1",TestDll1.class);
public int sayStr(char* szBufv,int Ito);
}
public static void main(String[] args) {
byte sz[] = new byte[8];
int Ito = 0;
int zdps = TestDll1.INSTANCE.sayStr(sz,Ito);
System.out.println("ito:" + Ito);
}
}
这段代码的意图是想从C++的Ito:2传给java中的Ito ,结果java中的Ito还是为0;即输出参数还是0
错误提示:
An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=4876, tid=2164
#
# Java VM: Java HotSpot(TM) Client VM (11.0-b15 mixed mode windows-x86)
# Problematic frame:
# C 0x00000000
#......