JNA - callback method with void* arguments
I have a C method that registers call back method with vendor provided dll. I have been told that the DLL makes the callback on a separate thread which it creates and controls.There are 3 possible different data messages that can be received by receive callback.
// Register user receive callback function
int PTOAPI_MODE PTOregReceivedCB(void (__stdcall *pUsrFunc3)(void* lpData,int iDataLen));
I have used JNAERATOR to create JAVA interface code which has generated below segment code,
/// <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);
I have ran the code in the simple main method to ensure i could get callback from dll which is shown below.
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);
}
});
.....
}
When I run my test, it successfully registers the callback with dll. But later when dll tries to invoke the callback method, jvm crashes even before it reaches the callback method in JAVA. Exception report shows that " The instruction at "0x0b543a46" referenced memory at "0x0651acc". The memory could not be 'read'" . I am suspecting that Pointer in the callback is failing. Could you see anything wrong with my code? Is there something I need for Pointer object in the callback? I am unable to read the Exception report below that was generated when JVM crashed. Your help will be greatly appreciated.
<?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" VE开发者_StackOverflowR_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]" />
....
...
You need to keep a strong reference to the java callback object, otherwise it will get garbage collected, and the JVM will crash when the native code tries to call it. See https://jna.dev.java.net/javadoc/com/sun/jna/Callback.html
e.g. This stores a reference to the callback in a static var in the class.
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);
}
};
Later in your main code, just do:
tofLib.PTOregReceivedCB(myCallback);
精彩评论