This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
catching exceptions in main() causes segfault?
- From: Adam Megacz <gcj at lists dot megacz dot com>
- To: java at gcc dot gnu dot org
- Date: 25 Feb 2002 19:30:43 -0800
- Subject: catching exceptions in main() causes segfault?
- Organization: Myself
Can anybody who understands GCC's exception handling better than I do
explain this?
Program 1: segfaults, apparently in longjmp() [tries to jump to invalid addr]
public class test {
public static void run() throws Exception {
throw new Exception();
}
public static void main(String[] s) {
try {
try { Thread.sleep(1000); } catch (Exception e) { }
run();
} catch (Exception e) {
System.out.println("caught!!!");
System.out.println(e);
}
}
}
Program 2: runs correctly
public class test {
public static void run() {
try {
try { Thread.sleep(1000); } catch (Exception e) { }
throw new Exception();
} catch (Exception e) {
System.out.println("caught!!!");
System.out.println(e);
}
}
public static void main(String[] s) {
run();
}
}
So it appears that I can't catch exceptions in main(), but anywhere
else works (even in other threads).
Wierd, huh?
- a