[liblouis-liblouisxml] Re: Java bindings for lou_registerLogCallback and lou_setLogLevel

  • From: "Michael Whapples" <dmarc-noreply@xxxxxxxxxxxxx> (Redacted sender "mwhapples@xxxxxxx" for DMARC)
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Thu, 12 Jun 2014 15:34:10 +0100

Hello,
I think my concern mostly relates to the possible result the user will experience.

Could the callback object being garbage collected lead to a crash of the JVM? If yes then that is probably not acceptable in my mind.

It it could only lead to a exception being thrown then its not quite so bad and may be let the application developer choose.

Michael Whapples
On 12/06/2014 14:13, Bert Frees wrote:
Hi Michael,

Good point.

No, JNA doesn't take care of that and neither do my bindings. It's
currently the responsibility of the calling application to keep a
reference to the callback object.

I guess I could make a convenience wrapper function that keeps a
reference for you, just like you do in the liblouisutdml
bindings. Something to be considered.

Thanks,
Bert



Michael Whapples writes:

Thanks for sharing that.

One thing I think I notice in that is that your bindings never take a
reference to the callback object. This is not a problem providing the
calling application uses it correctly, but should it not then
potentially the callback object could be garbage collected and then
liblouis may try and call it and things fall over. Is that correct or
does JNA do something?

In the LibLouisUTDML bindings I get the bindings to take and hold a
global reference to the callback object and only release that reference
when lou_registerLogCallback is called again (may it be called with NULL
to free the callback or another callback object).

Michael Whapples
On 12/06/2014 12:38, Bert Frees wrote:
Hello Michael,

I've updated my JNA based Java bindings to support
lou_registerLogCallback and lou_setLogLevel. See
https://github.com/liblouis/liblouis-java/commit/a30a1ad7212bed369c3ffd651c393ca241f83ae6
if you like to know how I did it.

Cheers,
Bert
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts: