From: jowenn Date: Sun, 14 Mar 2004 14:22:24 +0000 (+0000) Subject: testcase including fillInStackTrace and rethrow examples X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=582856bd30b921eb5e16a1fe5f9f90a4320cfedb;p=cacao.git testcase including fillInStackTrace and rethrow examples --- diff --git a/tests/stack/exception.java b/tests/stack/exception.java index 17075ba9f..bc65e869f 100644 --- a/tests/stack/exception.java +++ b/tests/stack/exception.java @@ -8,9 +8,57 @@ public class exception { } public static void a() throws Exception { - b(1); + try { + b(1); + } catch (Exception e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + System.out.println("Caught in a()"); + } + + b(2); } + public static void c() throws Exception{ + + try { + d(); + } catch (Exception e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + System.out.println("Caught in c(), rethrowing"); + throw e; + } + + + } + + public static void d() throws Exception{ + throw new Exception("Exception: value="+4); + } + + public static void e() throws Exception{ + + try { + f(); + } catch (Exception e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + System.out.println("Caught in c(), refilling stacktrace and rethrowing"); + e.fillInStackTrace(); + throw e; + } + + + } + + public static void f() throws Exception{ + System.out.println("Entering f"); + throw new Exception("Exception: value="+5); + } + + + public static void main(String args[]){ try { a(); @@ -20,7 +68,25 @@ public class exception { e.printStackTrace(); } try { - throw new Exception("2"); + throw new Exception("3"); + } + catch (Exception e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + + } + + try { + c(); + } + catch (Exception e) { + System.out.println(e.getMessage()); + e.printStackTrace(); + + } + + try { + e(); } catch (Exception e) { System.out.println(e.getMessage());