This is the mail archive of the
java-prs@sources.redhat.com
mailing list for the Java project.
Re: libgcj/289
- To: tromey at cygnus dot com
- Subject: Re: libgcj/289
- From: Bryce McKinlay <bryce at albatross dot co dot nz>
- Date: 11 Sep 2000 08:16:01 -0000
- Cc: java-prs at sourceware dot cygnus dot com,
- Reply-To: Bryce McKinlay <bryce at albatross dot co dot nz>
The following reply was made to PR libgcj/289; it has been noted by GNATS.
From: Bryce McKinlay <bryce@albatross.co.nz>
To: Tom Tromey <tromey@cygnus.com>
Cc: java-gnats@sourceware.cygnus.com
Subject: Re: libgcj/289
Date: Mon, 11 Sep 2000 20:05:45 +1200
Tom Tromey wrote:
> I experimented with the JDK. With the JDK interpreter, if the main
> thread throws an uncaught exception and then exits (because that was
> the last thread) then the runtime with exit with status 1.
>
> But consider the appended program. This program attempts to determine
> what happens if the main thread throws an exception but is not the
> last thread to stop. In this situation, what should happen? I don't
> know, because the JDK hangs. (Maybe there is a bug in my test, feel
> free to enlighten me.)
Interesting. It seems that in the JDK, a join() on a thread that throws an
unchecked exception never returns. This behaviour seems reasonable, I guess,
as a thread that throws an exception could potentially leave objects in an
unstable state. This is consistent across several different JDK versions (and
combinations of green/native threads), so perhaps we should look at
duplicating it.
> I don't think we should do anything special here. I agree it is less
> than perfect, but it isn't clear what the right thing is, and
> compatibility with the JDK seems hard.
If any thread throws unchecked, the JDK will exit with status 1 once the last
thread dies, unless another thread specifically calls System.exit() with a
different exit status. It should just be a matter of setting an error flag
somewhere and checking it in the exit routine.
> public class q implements Runnable
> {
> public static Thread t_bad, t_good;
>
>
> public boolean bad_flag;
>
> public void run () throws InterruptedException
There is a compiler bug here - this declaration should be illegal because
run() in Runnable does not throw InterruptedException. I can't duplicate this
for any class/interface other than Runnable, however. Strange.
regards
[ bryce ]