catching exceptions in main() causes segfault?
Adam Megacz
gcj@lists.megacz.com
Mon Feb 25 19:37:00 GMT 2002
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
More information about the Java
mailing list