JNative调用dll出现问题,帮忙看看!!!

2023-11-20 17:18

本文主要是介绍JNative调用dll出现问题,帮忙看看!!!,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

源码:

package com.bsoft.dll;import org.xvolks.jnative.JNative;
import org.xvolks.jnative.Type;
import org.xvolks.jnative.pointers.Pointer;
import org.xvolks.jnative.pointers.memory.MemoryBlockFactory;/*** 执行此函数需要把JNative.jar中的lib-bin\JNativeCpp.dll文件拷贝到C:\Windows\System32下;* 并且把zjnet.dll文件也拷贝到C:\Windows\System32下* @author LOVCC* @date 2011/12/28**/
public class JavaCallsDLL {//系统调用的dll文件名private static final String dllName = "zjnet.dll" ;//dll文件中定义的初始化函数private static final String initFunName = "InitSocketEnvironment" ;//dll文件中定义的交易函数private static final String tradeFunName = "SendDateToTXZFAndReceiveFromTXZF" ;//dll文件中定义的释放资源函数private static final String closeFunName = "FinalSocketEnvironment" ;//为返回消息而设置的内存大小private static final int memorySize = 65535 ;//JNative对象用于操作dll文件
//	private JNative jn = null ;//	private Pointer point ;/*** 初始化资源* @return 返回初始化的状态码* 			>0 代表成功* @throws Exception*/public int open() throws Exception {JNative jn = null ;jn = new JNative(dllName, initFunName) ;jn.setRetVal(Type.INT);jn.invoke() ;return jn.getRetValAsInt() ;}/*** 交易函数* @param send * @param receive * @return 返回执行函数的信息* 		   失败返回null* @throws Exception*/public String trade(String send, String receive) throws Exception{JNative jn = null ;jn = new JNative(dllName, tradeFunName) ;jn.setRetVal(Type.INT) ;Pointer point = null ;point= new Pointer(MemoryBlockFactory.createMemoryBlock(memorySize));point.setStringAt(0, receive) ;jn.setParameter(0, Type.STRING, send) ;jn.setParameter(1, point) ;jn.invoke() ;int i = jn.getRetValAsInt() ;String str = null ;if(i>=0){str = point.getAsString() ;}else {System.out.println("交易失败");}point.zeroMemory() ;point.dispose() ;return str ;}/*** 释放系统资源函数* @return* @throws Exception*/public String close() throws Exception{int i ;String message ;JNative jn = null ;jn = new JNative(dllName, closeFunName) ;jn.setRetVal(Type.INT);jn.invoke() ;i = jn.getRetValAsInt() ;if(i>0)message = "资源释放成功!" ;elsemessage = "资源释放失败!" ;return message ;}/*** 把以上三个函数封装* 调用函数直接执行* 初始化信息,进行交易,释放资源* 三步* @param send* @param receive* @return 返回交易信息*/public String getInfo(String send, String receive){String info = null ;try{int i = open() ;if(i>0){info = trade(send, receive) ;}else{System.out.println("建立连接失败") ;throw new Exception("建立连接失败") ;}System.out.println(close()) ;}catch(Exception e){e.printStackTrace() ;}return info ;}public static void main(String args[]){System.out.println(new JavaCallsDLL().getInfo("Exchcode=H888","ExchCode=H888&yydm=qd0100&qydm=370214")) ;}}

 程序报错:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x75932c70, pid=2492, tid=5892
#
# JRE version: 6.0_23-b05
# Java VM: Java HotSpot(TM) Client VM (19.0-b09 mixed mode, sharing windows-x86 )
# Problematic frame:
# C  [mswsock.dll+0x2c70]
#
# 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 (0x01a99400):  JavaThread "main" [_thread_in_native, id=5892, stack(0x00340000,0x00390000)]siginfo: ExceptionCode=0xc0000005, reading address 0x00000000Registers:
EAX=0x00000000, EBX=0x00000000, ECX=0x77d86500, EDX=0x04380180
ESP=0x00377760, EBP=0x00000000, ESI=0x000001f4, EDI=0x77473918
EIP=0x75932c70, EFLAGS=0x00010246Register to memory mapping:EAX=0x00000000
0x00000000 is pointing to unknown locationEBX=0x00000000
0x00000000 is pointing to unknown locationECX=0x77d86500
0x77d86500 is pointing to unknown locationEDX=0x04380180
0x04380180 is pointing to unknown locationESP=0x00377760
0x00377760 is pointing into the stack for thread: 0x01a99400
"main" prio=6 tid=0x01a99400 nid=0x1704 runnable [0x0038f000]java.lang.Thread.State: RUNNABLEEBP=0x00000000
0x00000000 is pointing to unknown locationESI=0x000001f4
0x000001f4 is pointing to unknown locationEDI=0x77473918
0x77473918 is pointing to unknown locationTop of Stack: (sp=0x00377760)
0x00377760:   00000002 000e0050 0037779c 03ee504e
0x00377770:   000001f4 00377798 04058e30 00000000
0x00377780:   77473962 000001f4 00377798 77473918
0x00377790:   000001f4 00000002 00000000 00000000
0x003777a0:   10001677 000001f4 00000000 0038fbe8
0x003777b0:   00000000 00000002 00000000 fffffffa
0x003777c0:   4f3c578f 00000000 003779e4 003779f1
0x003777d0:   000001b0 00000000 00000000 00000000 Instructions: (pc=0x75932c70)
0x75932c60:   00 00 00 3b fb 0f 85 83 c6 00 00 33 c0 5f 5e 5b
0x75932c70:   c9 c2 08 00 90 90 90 90 90 8b ff 55 8b ec 56 8b Stack: [0x00340000,0x00390000],  sp=0x00377760,  free space=221k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [mswsock.dll+0x2c70][error occurred during error reporting (printing native stack), id 0xc0000005]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+67
j  com.bsoft.dll.JavaCallsDLL.trade(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;+63
j  com.bsoft.dll.JavaCallsDLL.getInfo(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;+16
j  com.bsoft.dll.JavaCallsDLL.main([Ljava/lang/String;)V+14
v  ~StubRoutines::call_stub---------------  P R O C E S S  ---------------Java Threads: ( => current thread )0x01996800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=6324, stack(0x03dc0000,0x03e10000)]0x0198ec00 JavaThread "CompilerThread0" daemon [_thread_blocked, id=5736, stack(0x03d70000,0x03dc0000)]0x0198bc00 JavaThread "Attach Listener" daemon [_thread_blocked, id=8084, stack(0x03d20000,0x03d70000)]0x01988c00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=1312, stack(0x03cd0000,0x03d20000)]0x01947000 JavaThread "Finalizer" daemon [_thread_blocked, id=6184, stack(0x03c80000,0x03cd0000)]0x01942400 JavaThread "Reference Handler" daemon [_thread_blocked, id=8024, stack(0x03c30000,0x03c80000)]
=>0x01a99400 JavaThread "main" [_thread_in_native, id=5892, stack(0x00340000,0x00390000)]Other Threads:0x01940800 VMThread [stack: 0x03be0000,0x03c30000] [id=2512]0x019a8400 WatcherThread [stack: 0x03e10000,0x03e60000] [id=6328]VM state:not at safepoint (normal execution)VM Mutex/Monitor currently owned by a thread: NoneHeapdef new generation   total 4928K, used 677K [0x23760000, 0x23cb0000, 0x28cb0000)eden space 4416K,  15% used [0x23760000, 0x238094e8, 0x23bb0000)from space 512K,   0% used [0x23bb0000, 0x23bb0000, 0x23c30000)to   space 512K,   0% used [0x23c30000, 0x23c30000, 0x23cb0000)tenured generation   total 10944K, used 0K [0x28cb0000, 0x29760000, 0x33760000)the space 10944K,   0% used [0x28cb0000, 0x28cb0000, 0x28cb0200, 0x29760000)compacting perm gen  total 12288K, used 516K [0x33760000, 0x34360000, 0x37760000)the space 12288K,   4% used [0x33760000, 0x337e1380, 0x337e1400, 0x34360000)ro space 10240K,  54% used [0x37760000, 0x37cdc6b0, 0x37cdc800, 0x38160000)rw space 12288K,  55% used [0x38160000, 0x388001f0, 0x38800200, 0x38d60000)Dynamic libraries:
0x00400000 - 0x00424000 	C:\Program Files\Java\jdk1.6.0_23\bin\javaw.exe
0x77d30000 - 0x77e6c000 	C:\Windows\SYSTEM32\ntdll.dll
0x77740000 - 0x77814000 	C:\Windows\system32\kernel32.dll
0x76160000 - 0x761aa000 	C:\Windows\system32\KERNELBASE.dll
0x77ec0000 - 0x77f60000 	C:\Windows\system32\ADVAPI32.dll
0x77870000 - 0x7791c000 	C:\Windows\system32\msvcrt.dll
0x761b0000 - 0x761c9000 	C:\Windows\SYSTEM32\sechost.dll
0x762a0000 - 0x76341000 	C:\Windows\system32\RPCRT4.dll
0x773a0000 - 0x77469000 	C:\Windows\system32\USER32.dll
0x76250000 - 0x7629e000 	C:\Windows\system32\GDI32.dll
0x77eb0000 - 0x77eba000 	C:\Windows\system32\LPK.dll
0x776a0000 - 0x7773d000 	C:\Windows\system32\USP10.dll
0x77380000 - 0x7739f000 	C:\Windows\system32\IMM32.DLL
0x774b0000 - 0x7757c000 	C:\Windows\system32\MSCTF.dll
0x7c340000 - 0x7c396000 	C:\Program Files\Java\jdk1.6.0_23\jre\bin\msvcr71.dll
0x6d8a0000 - 0x6db4c000 	C:\Program Files\Java\jdk1.6.0_23\jre\bin\client\jvm.dll
0x74900000 - 0x74932000 	C:\Windows\system32\WINMM.dll
0x75df0000 - 0x75e3c000 	C:\Windows\system32\apphelp.dll
0x6d850000 - 0x6d85c000 	C:\Program Files\Java\jdk1.6.0_23\jre\bin\verify.dll
0x6d3d0000 - 0x6d3ef000 	C:\Program Files\Java\jdk1.6.0_23\jre\bin\java.dll
0x6d330000 - 0x6d338000 	C:\Program Files\Java\jdk1.6.0_23\jre\bin\hpi.dll
0x77ea0000 - 0x77ea5000 	C:\Windows\system32\PSAPI.DLL
0x6d890000 - 0x6d89f000 	C:\Program Files\Java\jdk1.6.0_23\jre\bin\zip.dll
0x66c40000 - 0x66c62000 	C:\Windows\System32\JNativeCpp.dll
0x77bd0000 - 0x77d2c000 	C:\Windows\system32\OLE32.dll
0x77920000 - 0x779af000 	C:\Windows\system32\OLEAUT32.DLL
0x10000000 - 0x1002c000 	C:\Windows\system32\zjnet.dll
0x7c140000 - 0x7c243000 	C:\Windows\system32\MFC71.DLL
0x779b0000 - 0x77a07000 	C:\Windows\system32\SHLWAPI.dll
0x7c3a0000 - 0x7c41b000 	C:\Windows\system32\MSVCP71.dll
0x77470000 - 0x774a5000 	C:\Windows\system32\WS2_32.dll
0x77e80000 - 0x77e86000 	C:\Windows\system32\NSI.dll
0x5d360000 - 0x5d36a000 	C:\Windows\system32\MFC71CHS.DLL
0x03ee0000 - 0x03f07000 	C:\Windows\system32\ikutm.dll
0x03f30000 - 0x03f42000 	C:\Program Files\Common Files\Thunder Network\NetMon\net_monitor1.0.2.25.dll
0x76380000 - 0x76fca000 	C:\Windows\system32\SHELL32.dll
0x75450000 - 0x75459000 	C:\Windows\system32\VERSION.dll
0x75ec0000 - 0x75ecb000 	C:\Windows\system32\profapi.dll
0x75930000 - 0x7596c000 	C:\Windows\system32\mswsock.dll
0x75430000 - 0x75436000 	C:\Windows\System32\wshqos.dll
0x75440000 - 0x75445000 	C:\Windows\system32\wshtcpip.DLL
0x75920000 - 0x75926000 	C:\Windows\system32\wship6.dllVM Arguments:
jvm_args: -Dfile.encoding=GBK 
java_command: com.bsoft.dll.JavaCallsDLL
Launcher Type: SUN_STANDARDEnvironment Variables:
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_23
CLASSPATH=.;C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc.jar;C:\PROGRA~1\IBM\SQLLIB\java\sqlj.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cu.jar;C:\PROGRA~1\IBM\SQLLIB\bin;C:\PROGRA~1\IBM\SQLLIB\tools\db2XTrigger.jar;C:\PROGRA~1\IBM\SQLLIB\java\common.jar
PATH=C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\oracle\product\10.2.0\client_2\bin;C:\Program Files\oracle10g\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs;C:\Program Files\Java\jdk1.6.0_23\bin;D:\android-sdk-windows\tools;C:\PROGRA~1\IBM\SQLLIB\BIN;C:\PROGRA~1\IBM\SQLLIB\FUNCTION;C:\PROGRA~1\IBM\SQLLIB\SAMPLES\REPL;D:\Maxthon\oracle10g;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Program Files\TortoiseSVN\bin
USERNAME=LOVCC
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 6 Model 23 Stepping 10, GenuineIntel---------------  S Y S T E M  ---------------OS: Windows 7 Build 7601 Service Pack 1CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 23 stepping 10, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3Memory: 4k page, physical 2056804k(943808k free), swap 4113608k(2481416k free)vm_info: Java HotSpot(TM) Client VM (19.0-b09) for windows-x86 JRE (1.6.0_23-b05), built on Nov 12 2010 15:00:43 by "java_re" with MS VC++ 7.1 (VS2003)time: Thu Feb 16 09:10:39 2012
elapsed time: 0 seconds
 唉,折腾一天了,百度,google都没有结果,麻烦了解的给看看!!!

这篇关于JNative调用dll出现问题,帮忙看看!!!的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/396187

相关文章

大数据小内存排序问题如何巧妙解决

《大数据小内存排序问题如何巧妙解决》文章介绍了大数据小内存排序的三种方法:数据库排序、分治法和位图法,数据库排序简单但速度慢,对设备要求高;分治法高效但实现复杂;位图法可读性差,但存储空间受限... 目录三种方法:方法概要数据库排序(http://www.chinasem.cn对数据库设备要求较高)分治法(常

Vue项目中Element UI组件未注册的问题原因及解决方法

《Vue项目中ElementUI组件未注册的问题原因及解决方法》在Vue项目中使用ElementUI组件库时,开发者可能会遇到一些常见问题,例如组件未正确注册导致的警告或错误,本文将详细探讨这些问题... 目录引言一、问题背景1.1 错误信息分析1.2 问题原因二、解决方法2.1 全局引入 Element

Python调用另一个py文件并传递参数常见的方法及其应用场景

《Python调用另一个py文件并传递参数常见的方法及其应用场景》:本文主要介绍在Python中调用另一个py文件并传递参数的几种常见方法,包括使用import语句、exec函数、subproce... 目录前言1. 使用import语句1.1 基本用法1.2 导入特定函数1.3 处理文件路径2. 使用ex

关于@MapperScan和@ComponentScan的使用问题

《关于@MapperScan和@ComponentScan的使用问题》文章介绍了在使用`@MapperScan`和`@ComponentScan`时可能会遇到的包扫描冲突问题,并提供了解决方法,同时,... 目录@MapperScan和@ComponentScan的使用问题报错如下原因解决办法课外拓展总结@

MybatisGenerator文件生成不出对应文件的问题

《MybatisGenerator文件生成不出对应文件的问题》本文介绍了使用MybatisGenerator生成文件时遇到的问题及解决方法,主要步骤包括检查目标表是否存在、是否能连接到数据库、配置生成... 目录MyBATisGenerator 文件生成不出对应文件先在项目结构里引入“targetProje

C#使用HttpClient进行Post请求出现超时问题的解决及优化

《C#使用HttpClient进行Post请求出现超时问题的解决及优化》最近我的控制台程序发现有时候总是出现请求超时等问题,通常好几分钟最多只有3-4个请求,在使用apipost发现并发10个5分钟也... 目录优化结论单例HttpClient连接池耗尽和并发并发异步最终优化后优化结论我直接上优化结论吧,

Java内存泄漏问题的排查、优化与最佳实践

《Java内存泄漏问题的排查、优化与最佳实践》在Java开发中,内存泄漏是一个常见且令人头疼的问题,内存泄漏指的是程序在运行过程中,已经不再使用的对象没有被及时释放,从而导致内存占用不断增加,最终... 目录引言1. 什么是内存泄漏?常见的内存泄漏情况2. 如何排查 Java 中的内存泄漏?2.1 使用 J

numpy求解线性代数相关问题

《numpy求解线性代数相关问题》本文主要介绍了numpy求解线性代数相关问题,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 在numpy中有numpy.array类型和numpy.mat类型,前者是数组类型,后者是矩阵类型。数组

解决systemctl reload nginx重启Nginx服务报错:Job for nginx.service invalid问题

《解决systemctlreloadnginx重启Nginx服务报错:Jobfornginx.serviceinvalid问题》文章描述了通过`systemctlstatusnginx.se... 目录systemctl reload nginx重启Nginx服务报错:Job for nginx.javas

Redis缓存问题与缓存更新机制详解

《Redis缓存问题与缓存更新机制详解》本文主要介绍了缓存问题及其解决方案,包括缓存穿透、缓存击穿、缓存雪崩等问题的成因以及相应的预防和解决方法,同时,还详细探讨了缓存更新机制,包括不同情况下的缓存更... 目录一、缓存问题1.1 缓存穿透1.1.1 问题来源1.1.2 解决方案1.2 缓存击穿1.2.1