This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the GCJ project. See the GCJ home page for more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hi, it appears that gcj does not yet implement stack overflow errors properly: the following program segfaults. Apropos segfaulting: it also appears as though NullPointerExceptions aren't properly caught (?). See the second test case. - Godmar // Overflow.java /** * Check that stack overflows are handled properly in main thread and * other threads. * * @author Godmar Back <gback@cs.utah.edu> */ public class Overflow extends Thread { public void run() { try { recurse(); } catch (StackOverflowError e) { System.out.println("Success."); } } void recurse() { recurse(); } public static void main(String av[]) throws Exception { Overflow o = new Overflow(); o.run(); // check for main thread o.start(); // check for other thread o.join(); } } /* Expected Output: Success. Success. */ // NullPointerTest.java /* * test that caught null pointers exceptions in finalizers work correctly * and that local variables are accessible in null pointer exception handlers. */ import java.io.*; public class NullPointerTest { static String s; public static void main(String[] args) { System.out.println(tryfinally() + s); } public static String tryfinally() { String yuck = null; String local_s = null; try { return "This is "; } finally { try { local_s = "Perfect"; /* trigger null pointer exception */ String x = yuck.toLowerCase(); } catch (Exception _) { /* * when the null pointer exception is caught, we must still * be able to access local_s. * Our return address for the finally clause must also still * be intact. */ s = local_s; } } } } /* Expected Output: This is Perfect */