2 messages in net.java.dev.jna.usersRe: [jna-users] FW: Invalid memory ac...
FromSent OnAttachments
Daniel ThornhillDec 12, 2008 7:57 am 
Timothy WallDec 12, 2008 4:27 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] FW: Invalid memory accessActions...
From:Timothy Wall (twal@dev.java.net)
Date:Dec 12, 2008 4:27:30 pm
List:net.java.dev.jna.users

PVOID is Pointer, not PointerByReference, although that won't make any difference if you don't access the arguments.

If the error is happening after the callback returns, then your calling convention may be incorrect, or your arguments incorrectly mapped on either the called function or the callback.

On Dec 12, 2008, at 10:58 AM, Daniel Thornhill wrote:

Hi all, Wondering if you could help me. I am trying to implement a call back function for my c/c++. The call back function is call but then I get the error,

Exception in thread "main" java.lang.Error: Invalid memory access at com.sun.jna.Function.invokeInt(Native Method) at com.sun.jna.Function.invoke(Function.java:298) at com.sun.jna.Function.invoke(Function.java:223) at com.sun.jna.Library$Handler.invoke(Library.java:204) at $Proxy0.DivaDial(Unknown Source) at com.validsoft.tools.telephony.eicondiva.jna.test.Test.main(Test.java: 29)

The C function I am trying to connect to has the signature,

static void CallbackHandler ( DivaAppHandle hApp, DivaEvent Event, PVOID Param1, PVOID Param2 )

and the Java I have written is,

public interface DivaCallbackHandler extends Callback { public void callback( Pointer hApp, int Event, PointerByReference param1, PointerByReference param2 ); }

and…

public class CallbackHandler implements DivaCallbackHandler {

public void callback(Pointer hApp, int event, PointerByReference param1, PointerByReference param2) {

System.out.println("CallbackHandler.CallbackHandler():: I have been called back!!"); }

}

I get the System.out line written to the console, and the it fails - and ideas? I have tried using IntByReference for PVOID parameters as well.

ValidSoft Ltd is a Private Limited Company. ValidSoft Ltd, Castle Buildings, Tara Street, Tullamore, Co Offaly, Ireland. Registration Number: 377068 Registered in Dublin.