From 204274dc0529ecbbaa20d72eec49a14ddf4ba34c Mon Sep 17 00:00:00 2001 From: acolyer Date: Mon, 14 Mar 2005 02:17:51 +0000 Subject: [PATCH] test cases for Bugzilla Bug 42743: declare soft limitation --- tests/decs/DeclareSoftRuntimeException.aj | 41 +++++++++++++++++++ tests/decs/VerifyError.aj | 23 +++++++++++ .../systemtest/ajc150/Ajc150Tests.java | 10 ++++- .../org/aspectj/systemtest/ajc150/ajc150.xml | 19 +++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 tests/decs/DeclareSoftRuntimeException.aj create mode 100644 tests/decs/VerifyError.aj diff --git a/tests/decs/DeclareSoftRuntimeException.aj b/tests/decs/DeclareSoftRuntimeException.aj new file mode 100644 index 000000000..379ba645c --- /dev/null +++ b/tests/decs/DeclareSoftRuntimeException.aj @@ -0,0 +1,41 @@ +public aspect DeclareSoftRuntimeException { + + declare soft : MyRuntimeException : execution(* *(..)); + declare soft : MyException : execution(* *(..)); + declare soft : Exception : execution(void throwMyExceptionButNotReally()); + + public static void main(String[] args) { + try { + throwMyRuntimeException(); + } catch(Exception ex) { + System.out.println(ex.getClass().getName()); + } + try { + throwMyException(); + } catch(Exception ex) { + System.out.println(ex.getClass().getName()); + } + try { + throwMyExceptionButNotReally(); + } catch(Exception ex) { + System.out.println(ex.getClass().getName()); + } + } + + private static void throwMyRuntimeException() { + throw new MyRuntimeException(); + } + + private static void throwMyException() throws MyException { + throw new MyException(); + } + + private static void throwMyExceptionButNotReally() throws MyException { + throw new MyRuntimeException(); + } + +} + +class MyRuntimeException extends RuntimeException {} + +class MyException extends Exception {} diff --git a/tests/decs/VerifyError.aj b/tests/decs/VerifyError.aj new file mode 100644 index 000000000..835748770 --- /dev/null +++ b/tests/decs/VerifyError.aj @@ -0,0 +1,23 @@ +import java.io.IOException; +import org.aspectj.lang.SoftException; + +public class VerifyError { + + static void foo() throws IOException { + throw new IOException(); + } + + public static void main(String[] args) throws Exception{ + try { + foo(); + } catch (SoftException sEx) { + // + } + } +} + + +aspect Soften { + + declare soft : IOException : call(* foo()); +} \ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 82e1aed27..a1aeb6d77 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -111,7 +111,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void test051_arrayCloningInJava5() { runTest("AJC possible bug with static nested classes"); } - + public void testBadASMforEnums() throws IOException { runTest("bad asm for enums"); @@ -128,6 +128,14 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void npeOnTypeNotFound() { runTest("structure model npe on type not found"); } + + public void testNoRuntimeExceptionSoftening() { + runTest("declare soft of runtime exception"); + } + + public void testRuntimeNoSoftenWithHandler() { + runTest("declare soft w. catch block"); + } // helper methods..... diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 666ad0d33..2e165f3a8 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -54,6 +54,25 @@ + + + + + + + + + + + + + + + + + + + -- 2.39.5