Question: Uncaught Exceptions in GIJ
Andrew Haley
aph@redhat.com
Fri Jul 7 14:35:00 GMT 2006
Kyle Galloway writes:
> I have a question about GIJ. I was wondering how/where GIJ decides that
> an exception is unhandled (i.e. that nowhere along the call stack the
> exception was caught).
In fact *every* exception is caught by a global catch-all handler in
the outermost frame. Here:
void
_Jv_ThreadRun (java::lang::Thread* thread)
{
try
{
_Jv_NotifyThreadStart (thread);
thread->run ();
}
catch (java::lang::Throwable *t)
{
// Uncaught exceptions are forwarded to the ThreadGroup. If
// this results in an uncaught exception, that is ignored.
try
{
thread->group->uncaughtException (thread, t);
}
catch (java::lang::Throwable *f)
{
// Nothing.
}
}
thread->finish_ ();
}
and here:
/**
* When a Thread in this ThreadGroup does not catch an exception, the
* virtual machine calls this method. The default implementation simply
* passes the call to the parent; then in top ThreadGroup, it will
* ignore ThreadDeath and print the stack trace of any other throwable.
* Override this method if you want to handle the exception in a different
* manner.
*
* @param thread the thread that exited
* @param t the uncaught throwable
* @throws NullPointerException if t is null
* @see ThreadDeath
* @see System#err
* @see Throwable#printStackTrace()
*/
public void uncaughtException(Thread thread, Throwable t)
{
...
Andrew.
More information about the Java
mailing list