This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Question: Uncaught Exceptions in GIJ
- From: Andrew Haley <aph at redhat dot com>
- To: Kyle Galloway <kgallowa at redhat dot com>
- Cc: java at gcc dot gnu dot org
- Date: Fri, 7 Jul 2006 15:34:51 +0100
- Subject: Re: Question: Uncaught Exceptions in GIJ
- References: <44AE653D.2010909@redhat.com>
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.