我有一个C方法,它使用供应商提供的dll注册回调方法。我被告知DLL在一个单独的线程上进行回调,它创建和控制。接收回调可以接收3种可能的不同数据消息。
// Register user receive callback function
int PTOAPI_MODE PTOregReceivedCB(void (__stdcall *pUsrFunc3)(void* lpData,int iDataLen));
我已经使用JNAERATOR来创建JAVA接口代码,该代码生成了以下段代码,
/// <i>native declaration : Ptsptoext.h:728</i>
public interface pUsrFunc3 extends Callback {
void invoke(Pointer lpData, int iDataLen);
}
/**
* Original signature : <code>PTOregReceivedCB(pUsrFunc3)</code><br>
* <i>native declaration : Ptsptoext.h:728</i>
*/
@Mangling({"_Z16PTOregReceivedCBPFvPviE", "?PTOregReceivedCB@@YAXPFXPAXH@E@Z"})
int PTOregReceivedCB(TofapiLibrary.pUsrFunc3 arg3);
我已经在简单的main方法中运行了代码,以确保我可以从dll获得回调,如下所示。
main(){
...
success = tofLib.PTOregReceivedCB(new TofapiLibrary.pUsrFunc3() {
@Override
synchronized public void invoke(Pointer lpData, int iDataLen) {
System.out.println("PTOregRecievedCB has been called with data lenght = " + iDataLen);
}
});
.....
}
当我运行测试时,它成功地使用dll注册回调。但是后来当dll尝试调用回调方法时,jvm甚至在它到达JAVA中的回调方法之前就崩溃了。异常报告显示“0x0b543a46”处的指令引用了“0x0651acc”处的内存。内存无法“读取”。我怀疑回调中的指针失败了。你能看到我的代码有什么问题吗?在回调中我是否需要Pointer对象?我无法读取JVM崩溃时生成的以下异常报告。非常感谢您的帮助。
<?xml version="1.0" encoding="UTF-16"?>
<DATABASE>
<EXE NAME="javaw.exe" FILTER="GRABMI_FILTER_PRIVACY">
<MATCHING_FILE NAME="appletviewer.exe" SIZE="27648" CHECKSUM="0xE4DA62B" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="appletviewer.exe" INTERNAL_NAME="appletviewer" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:26:29" UPTO_LINK_DATE="10/11/2009 09:26:29" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="apt.exe" SIZE="27648" CHECKSUM="0x4886AA8F" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="apt.exe" INTERNAL_NAME="apt" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:06:02" UPTO_LINK_DATE="10/11/2009 09:06:02" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="beanreg.dll" SIZE="29184" CHECKSUM="0x95341105" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="beanreg.dll" INTERNAL_NAME="JavaBeans(TM) Registration Library" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0xBAE6" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 12:17:12" UPTO_LINK_DATE="10/11/2009 12:17:12" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="extcheck.exe" SIZE="27648" CHECKSUM="0x31491C81" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="extcheck.exe" INTERNAL_NAME="extcheck" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:41:10" UPTO_LINK_DATE="10/11/2009 09:41:10" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="HtmlConverter.exe" SIZE="49152" CHECKSUM="0x99A495AD" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="htmlConverter.exe" INTERNAL_NAME="HTML Converter for Java(TM) Plug-in" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 10:13:14" UPTO_LINK_DATE="10/11/2009 10:13:14" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="idlj.exe" SIZE="27648" CHECKSUM="0xF672F04D" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="idlj.exe" INTERNAL_NAME="idlj" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:14:24" UPTO_LINK_DATE="10/11/2009 09:14:24" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="jar.exe" SIZE="27648" CHECKSUM="0xABE2B6CD" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="jar.exe" INTERNAL_NAME="jar" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:17:40" UPTO_LINK_DATE="10/11/2009 09:17:40" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="jarsigner.exe" SIZE="27648" CHECKSUM="0x756473A1" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="jarsigner.exe" INTERNAL_NAME="jarsigner" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:17:07" UPTO_LINK_DATE="10/11/2009 09:17:07" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="java-rmi.exe" SIZE="27136" CHECKSUM="0x3A410C90" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="java-rmi.exe" INTERNAL_NAME="java-rmi" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:28:23" UPTO_LINK_DATE="10/11/2009 09:28:23" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="java.exe" SIZE="139264" CHECKSUM="0x8364FE93" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="java.exe" INTERNAL_NAME="java" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:02:39" UPTO_LINK_DATE="10/11/2009 09:02:39" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="javac.exe" SIZE="27648" CHECKSUM="0x7BBD90EB" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="javac.exe" INTERNAL_NAME="javac" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:03:25" UPTO_LINK_DATE="10/11/2009 09:03:25" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="javadoc.exe" SIZE="27648" CHECKSUM="0x255FE957" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="javadoc.exe" INTERNAL_NAME="javadoc" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:05:49" UPTO_LINK_DATE="10/11/2009 09:05:49" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="javah.exe" SIZE="27648" CHECKSUM="0xD60E69D0" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="javah.exe" INTERNAL_NAME="javah" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:06:14" UPTO_LINK_DATE="10/11/2009 09:06:14" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="javap.exe" SIZE="27648" CHECKSUM="0xBE1F954A" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="javap.exe" INTERNAL_NAME="javap" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:32:31" UPTO_LINK_DATE="10/11/2009 09:32:31" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="javaw.exe" SIZE="139264" CHECKSUM="0xF576898B" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="javaw.exe" INTERNAL_NAME="javaw" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:02:45" UPTO_LINK_DATE="10/11/2009 09:02:45" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="javaws.exe" SIZE="143360" CHECKSUM="0xABC8B43B" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Web Start Launcher" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="javaws.exe" INTERNAL_NAME="Java(TM) Web Start Launcher" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 10:01:31" UPTO_LINK_DATE="10/11/2009 10:01:31" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="jconsole.exe" SIZE="28160" CHECKSUM="0xEC7B0127" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="jconsole.exe" INTERNAL_NAME="jconsole" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:33:31" UPTO_LINK_DATE="10/11/2009 09:33:31" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="jdb.exe" SIZE="27648" CHECKSUM="0xD3445406" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="jdb.exe" INTERNAL_NAME="jdb" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:42:54" UPTO_LINK_DATE="10/11/2009 09:42:54" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="jhat.exe" SIZE="27648" CHECKSUM="0x20AA78F3" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="jhat.exe" INTERNAL_NAME="jhat" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:33:47" UPTO_LINK_DATE="10/11/2009 09:33:47" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="jinfo.exe" SIZE="27648" CHECKSUM="0xB23EFDD3" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="jinfo.exe" INTERNAL_NAME="jinfo" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:33:18" UPTO_LINK_DATE="10/11/2009 09:33:18" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="jli.dll" SIZE="77824" CHECKSUM="0x4306136A" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="jli.dll" INTERNAL_NAME="jli" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0x18807" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 12:17:12" UPTO_LINK_DATE="10/11/2009 12:17:12" VER_LANGUAGE="Language Neutral [0x0]" />
<MATCHING_FILE NAME="jmap.exe" SIZE="27648" CHECKSUM="0x732030B3" BIN_FILE_VERSION="6.0.170.4" BIN_PRODUCT_VERSION="6.0.170.4" PRODUCT_VERSION="6.0.170.4" FILE_DESCRIPTION="Java(TM) Platform SE binary" COMPANY_NAME="Sun Microsystems, Inc." PRODUCT_NAME="Java(TM) Platform SE 6 U17" FILE_VERSION="6.0.170.4" ORIGINAL_FILENAME="jmap.exe" INTERNAL_NAME="jmap" LEGAL_COPYRIGHT="Copyright © 2004" VERFILEDATEHI="0x0" VERFILEDATELO="0x0" VERFILEOS="0x4" VERFILETYPE="0x1" MODULE_TYPE="WIN32" PE_CHECKSUM="0x0" LINKER_VERSION="0x0" UPTO_BIN_FILE_VERSION="6.0.170.4" UPTO_BIN_PRODUCT_VERSION="6.0.170.4" LINK_DATE="10/11/2009 09:33:13" UPTO_LINK_DATE="10/11/2009 09:33:13" VER_LANGUAGE="Language Neutral [0x0]" />
....
...
答案 0 :(得分:2)
你需要保持对java回调对象的强引用,否则它将被垃圾收集,并且当本机代码试图调用它时JVM将崩溃。见https://jna.dev.java.net/javadoc/com/sun/jna/Callback.html
e.g。这将在类中的静态var中存储对回调的引用。
static final TofapiLibrary.pUsrFunc3 myCallback = new TofapiLibrary.pUsrFunc3() {
@Override
synchronized public void invoke(Pointer lpData, int iDataLen) {
System.out.println("PTOregRecievedCB has been called with data lenght = " + iDataLen);
}
};
稍后在主代码中,执行:
tofLib.PTOregReceivedCB(myCallback);