1 message in net.java.dev.jna.usersCallbacks and exceptions
FromSent OnAttachments
Albert StrasheimMar 27, 2008 5:44 am 
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:Callbacks and exceptionsActions...
From:Albert Strasheim (full@gmail.com)
Date:Mar 27, 2008 5:44:07 am
List:net.java.dev.jna.users

Hello

I recently had a situation where I wrote a callback that called another function that threw a RuntimeException.

For the longest time I couldn't figure out why my JUnit test wasn't failing. The reason is obvious now: JNA prints the exception to stderr, since there isn't really anything else it can do with it.

However, it seems to me like this could lead to failures passing by unnoticed. I think it would be useful if JNA could be configured (maybe on a per-library basis) as to how it should deal with uncaught exceptions, analogous to Thread's setUncaughtExceptionHandler and setDefaultUncaughtExceptionHandler.

This way, I can log the exception using log4j and then exit the VM, or maybe set a flag that my JUnit tests can check.

Cheers,

Albert