JNative 調用 dll時候,JDK報“Java VM”錯誤

在我調用JNative的時候,
動態庫是delphi寫的,定義如下

Function read_qh_ws_cpu(isComPort,isReaderType:string;
var Cardtype:Pchar;
var ReadCard_data:Pchar;
var Read_Otherdata:Pchar):integer;stdcall;
far;external 'IC_WS_CPU.dll'name 'read_qh_ws_cpu';

java中通過JNative調用,實現如下:
/**
*
*/
package jnative;

import org.xvolks.jnative.JNative;
import org.xvolks.jnative.exceptions.NativeException;
import org.xvolks.jnative.pointers.Pointer;
import org.xvolks.jnative.pointers.memory.MemoryBlockFactory;
import org.xvolks.jnative.Type;

import java.lang.reflect.*;
import java.io.*;

/**
* @author Administrator
*
*/
public class ReadCard {

static JNative Something = null;
static Pointer pointer;

public String strCom="01";
public String strReaderType="1";
public Pointer pCardtype;
public Pointer pReadCard_data;
public Pointer pRead_Otherdata;


public int getInfoReadCard( String sCom,
String sReaderType,
Pointer pCardtype,
Pointer pReadCard_data,
Pointer pRead_Otherdata)
throws NativeException, IllegalAccessException
{

try{
if(Something == null)
{
//分配指針變量的內存大小
pCardtype = new Pointer(MemoryBlockFactory.createMemoryBlock(10));

pReadCard_data = new Pointer(MemoryBlockFactory.createMemoryBlock(1024));
pRead_Otherdata = new Pointer(MemoryBlockFactory.createMemoryBlock(20480));

pointer = new Pointer(MemoryBlockFactory.createMemoryBlock(10+1024+20480));



Something = new JNative("IC_WS_CPU.dll", "read_qh_ws_cpu");

// 指定返回參數的類型 dll文件中SCHelp_HexStringToBytes函數返回類型定義是“long”型
Something.setRetVal(Type.INT);
}

int i=0;
Something.setParameter(i++,Type.STRING, sCom);
Something.setParameter(i++,Type.STRING,sReaderType);


Something.setParameter(i++,pCardtype);
Something.setParameter(i++,pReadCard_data);
Something.setParameter(i++,pRead_Otherdata);
System.out.println("調用的DLL文件名爲:"+Something.getDLLName());
System.out.println("調用的方法名爲:"+Something.getFunctionName());
//傳值
Something.invoke();//調用方法
return Integer.parseInt(Something.getRetVal());
}finally{
if(Something!=null){
Something.dispose();//釋放
}
}
}


/**
* @param args
*/
public static void main(String[] args) throws NativeException, IllegalAccessException
{
// TODO Auto-generated method stub

ReadCard rc = new ReadCard();
int result = rc.getInfoReadCard(rc.strCom,rc.strReaderType,rc.pCardtype,rc.pReadCard_data,rc.pRead_Otherdata);
System.err.println("轉換成功的字節數爲:"+result);
//TestCallback.runIt();

}

}


但是運行後,報如下log錯誤:
請幫忙分析一下!謝謝!
郵箱[email protected]


------------------------------------------------------------------------------------
#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x02e37b1a, pid=4008, tid=456
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0-beta2-b86 mixed mode, sharing)
# Problematic frame:
# C [IC_WS_CPU.dll+0x7b1a]
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#

--------------- T H R E A D ---------------

Current thread (0x003f5800): JavaThread "main" [_thread_in_native, id=456]

siginfo: ExceptionCode=0xc0000005, reading address 0x03be1030

Registers:
EAX=0x010d0159, EBX=0x00000001, ECX=0x00000000, EDX=0x008ff9bc
ESP=0x008ff974, EBP=0x008ff9bc, ESI=0x010d0159, EDI=0x02b10ed8
EIP=0x02e37b1a, EFLAGS=0x00010202

Top of Stack: (sp=0x008ff974)
0x008ff974: 008ff9e4 000a71b8 00000000 00000000
0x008ff984: 02e7e971 0090fdc8 02e7eb70 008ff9e4
0x008ff994: 00000000 00000000 00000000 00000000
0x008ff9a4: 00000000 00000000 00000000 00000000
0x008ff9b4: 00000000 00000000 00000000 00000000
0x008ff9c4: 00000000 00000000 00000000 00000000
0x008ff9d4: 00000000 00000000 00000000 00000000
0x008ff9e4: 0090fc08 100047c3 02b10ed8 02b7ccf0

Instructions: (pc=0x02e37b1a)
0x02e37b0a: 76 f4 3b f3 7d 0a 8b c5 e8 81 c3 ff ff eb 17 4e
0x02e37b1a: 80 7c 37 ff 20 76 f8 55 8b ce 2b cb 41 8b d3 8b


Stack: [0x008c0000,0x00910000), sp=0x008ff974, free space=254k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [IC_WS_CPU.dll+0x7b1a]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.xvolks.jnative.JNative.nInvoke(I)V+0
j org.xvolks.jnative.JNative.invoke()V+9
j jnative.ReadCard.getInfoReadCard(Ljava/lang/String;Ljava/lang/String;Lorg/xvolks/jnative/pointers/Pointer;Lorg/xvolks/jnative/pointers/Pointer;Lorg/xvolks/jnative/pointers/Pointer;)I+216
j jnative.ReadCard.main([Ljava/lang/String;)V+29
v ~StubRoutines::call_stub

--------------- P R O C E S S ---------------

Java Threads: ( => current thread )
0x02ae4800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3536]
0x02ae2000 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3328]
0x02ae0c00 JavaThread "Attach Listener" daemon [_thread_blocked, id=2808]
0x02afdc00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=3772]
0x02aa1800 JavaThread "Finalizer" daemon [_thread_blocked, id=3336]
0x02a9d000 JavaThread "Reference Handler" daemon [_thread_blocked, id=3896]
=>0x003f5800 JavaThread "main" [_thread_in_native, id=456]

Other Threads:
0x02a94000 VMThread [id=2172]
0x02ae6000 WatcherThread [id=2076]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
def new generation total 960K, used 615K [0x229d0000, 0x22ad0000, 0x22eb0000)
eden space 896K, 68% used [0x229d0000, 0x22a69e50, 0x22ab0000)
from space 64K, 0% used [0x22ab0000, 0x22ab0000, 0x22ac0000)
to space 64K, 0% used [0x22ac0000, 0x22ac0000, 0x22ad0000)
tenured generation total 4096K, used 0K [0x22eb0000, 0x232b0000, 0x269d0000)
the space 4096K, 0% used [0x22eb0000, 0x22eb0000, 0x22eb0200, 0x232b0000)
compacting perm gen total 12288K, used 547K [0x269d0000, 0x275d0000, 0x2a9d0000)
the space 12288K, 4% used [0x269d0000, 0x26a58e70, 0x26a59000, 0x275d0000)
ro space 8192K, 67% used [0x2a9d0000, 0x2af35520, 0x2af35600, 0x2b1d0000)
rw space 12288K, 56% used [0x2b1d0000, 0x2b89c188, 0x2b89c200, 0x2bdd0000)

Dynamic libraries:
0x00400000 - 0x00423000 D:\MyEclipse 6.0\jdk1.6.0\bin\javaw.exe
0x7c920000 - 0x7c9b3000 C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c91e000 C:\WINDOWS\system32\kernel32.dll
0x77da0000 - 0x77e49000 C:\WINDOWS\system32\ADVAPI32.dll
0x77e50000 - 0x77ee2000 C:\WINDOWS\system32\RPCRT4.dll
0x77fc0000 - 0x77fd1000 C:\WINDOWS\system32\Secur32.dll
0x77d10000 - 0x77da0000 C:\WINDOWS\system32\USER32.dll
0x77ef0000 - 0x77f39000 C:\WINDOWS\system32\GDI32.dll
0x76300000 - 0x7631d000 C:\WINDOWS\system32\IMM32.DLL
0x62c20000 - 0x62c29000 C:\WINDOWS\system32\LPK.DLL
0x73fa0000 - 0x7400b000 C:\WINDOWS\system32\USP10.dll
0x7c340000 - 0x7c396000 D:\MyEclipse 6.0\jdk1.6.0\jre\bin\msvcr71.dll
0x6d7f0000 - 0x6da2f000 D:\MyEclipse 6.0\jdk1.6.0\jre\bin\client\jvm.dll
0x76b10000 - 0x76b3a000 C:\WINDOWS\system32\WINMM.dll
0x6d310000 - 0x6d318000 D:\MyEclipse 6.0\jdk1.6.0\jre\bin\hpi.dll
0x76bc0000 - 0x76bcb000 C:\WINDOWS\system32\PSAPI.DLL
0x6d7a0000 - 0x6d7ac000 D:\MyEclipse 6.0\jdk1.6.0\jre\bin\verify.dll
0x6d3a0000 - 0x6d3bf000 D:\MyEclipse 6.0\jdk1.6.0\jre\bin\java.dll
0x6d7e0000 - 0x6d7ef000 D:\MyEclipse 6.0\jdk1.6.0\jre\bin\zip.dll
0x10000000 - 0x100cd000 D:\MyEclipse 6.0\jdk1.6.0\jre\bin\JNativeCpp.dll
0x77be0000 - 0x77c38000 C:\WINDOWS\system32\msvcrt.dll
0x02e30000 - 0x02e91000 D:\mywork\project\java\MyCommText\bin\qh\IC_WS_CPU.dll
0x770f0000 - 0x7717b000 C:\WINDOWS\system32\oleaut32.dll
0x76990000 - 0x76acd000 C:\WINDOWS\system32\ole32.dll
0x77bd0000 - 0x77bd8000 C:\WINDOWS\system32\version.dll
0x02ea0000 - 0x02f14000 D:\mywork\project\java\MyCommText\bin\qh\WSCPU.dll
0x02f20000 - 0x02f43000 D:\mywork\project\java\MyCommText\bin\qh\WDCRWV.DLL
0x02f50000 - 0x02f76000 D:\mywork\project\java\MyCommText\bin\qh\WDPublic.DLL
0x02f80000 - 0x02f88000 D:\mywork\project\java\MyCommText\bin\qh\XjCpuPre.dll
0x02f90000 - 0x02f98000 D:\mywork\project\java\MyCommText\bin\qh\PCSC.dll
0x02fa0000 - 0x02faa000 D:\mywork\project\java\MyCommText\bin\qh\Mdes.dll
0x73d30000 - 0x73e2e000 C:\WINDOWS\system32\MFC42.DLL
0x72360000 - 0x7237a000 C:\WINDOWS\system32\WinSCard.dll
0x76f20000 - 0x76f28000 C:\WINDOWS\system32\WTSAPI32.dll
0x762d0000 - 0x762e0000 C:\WINDOWS\system32\WINSTA.dll
0x5fdd0000 - 0x5fe25000 C:\WINDOWS\system32\NETAPI32.dll
0x02fb0000 - 0x02fb8000 D:\mywork\project\java\MyCommText\bin\qh\CPU.dll
0x5d170000 - 0x5d20a000 C:\WINDOWS\system32\comctl32.dll
0x61be0000 - 0x61bed000 C:\WINDOWS\system32\MFC42LOC.DLL

VM Arguments:
java_command: jnative.ReadCard
Launcher Type: SUN_STANDARD

Environment Variables:
JAVA_HOME=D:\MyEclipse 6.0\jdk1.6.0
CLASSPATH=.;D:\MyEclipse 6.0\Tomcat 6.0\common\lib;D:\MyEclipse 6.0\jdk1.6.0\bin;D:\MyEclipse 6.0\jdk1.6.0\lib;D:\MyEclipse 6.0\jdk1.6.0\lib\dt.jar;D:\MyEclipse 6.0\jdk1.6.0\lib\tools.jar;D:\MyEclipse 6.0\jdk1.6.0\lib\comm.jar
PATH=C:\Program Files\Borland\Delphi7\Bin;C:\Program Files\Borland\Delphi7\Projects\Bpl\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\documents and settings\administrator\桌面\dws\dws\lib\;D:\mywork\project\java\MyCommText\bin\qh\;C:\Program Files\StormII\Codec;C:\Program Files\StormII;D:\Program Files\UltraEdit_V14\;D:\Program Files\UltraEdit_V14\UltraCompare
USERNAME=Administrator
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 14 Stepping 8, GenuineIntel


--------------- S Y S T E M ---------------

OS: Windows XP Build 2600 Service Pack 3

CPU:total 1 family 6, cmov, cx8, fxsr, mmx, sse, sse2

Memory: 4k page, physical 1046640k(190404k free), swap 2518656k(1599712k free)

vm_info: Java HotSpot(TM) Client VM (1.6.0-beta2-b86) for windows-x86, built on Jun 2 2006 00:36:31 by "java_re" with unknown MS VC++:1310


------------------------------------------------------------------------------------
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章