1 message in net.java.dev.jna.usersRe: [jna-users] Callbacks not working...
FromSent OnAttachments
Timothy WallJun 18, 2007 12:50 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] Callbacks not working at allActions...
From:Timothy Wall (twal@dev.java.net)
Date:Jun 18, 2007 12:50:53 pm
List:net.java.dev.jna.users

On Jun 18, 2007, at 3:27 PM, Daniel Horowitz wrote:

My DLL is a message pump that consumes messages by invoking callbacks. My end goal is to have the callbacks be java functions but I am not there yet. Instead, I have the callbacks as C functions in the dll that just print to console. This works fine in a pure c environment.

In JNA, I am able to load my dll, but the C callbacks dont work at all. Instead, the DllMain function gets invoked repeatedly.

My questions is, given a message pump scenario, where the C dll has a main loop in a thread that waits for events, would JNA work? Does JNA keep the dll around or is it destroying and reloading it (explaining why DllMain gets called over and over).

If you are concerned that the DLL is unloaded, keep a reference to your java interface instance as returned by Native.loadLibrary or the corresponding NativeLibrary instance. It might make sense to throw some hooks in the NativeLibrary finalizer to determine if in fact your DLL is being unloaded (I wouldn't expect it to be possible to unload the DLL if there is an active thread executing its code, but I'm by no means a w32 expert).

If your dll *is* being unloaded, then that would explain why it has no extant list of callbacks to be called.