diff options
author | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
commit | 144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch) | |
tree | b12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/DeclareSoft.java | |
parent | fafae443719b26159ab2d7dac1c9b46b5e00b671 (diff) | |
download | aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip |
initial version
Diffstat (limited to 'tests/new/DeclareSoft.java')
-rw-r--r-- | tests/new/DeclareSoft.java | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/new/DeclareSoft.java b/tests/new/DeclareSoft.java new file mode 100644 index 000000000..095963f5b --- /dev/null +++ b/tests/new/DeclareSoft.java @@ -0,0 +1,84 @@ +import org.aspectj.testing.Tester; +import java.io.*; +import org.aspectj.lang.*; + +public class DeclareSoft { + public static void main(String[] args) { + new C().m1(); + try { + new C().m2(); + } catch (SoftException se) { + Tester.note("m2-soft"); + } + + try { + new C().m3(); + } catch (SoftException se) { + Tester.check(false, "already caught"); + } + + try { + new C().throwIt(); + } catch (SoftException se) { + Tester.note("throwIt-soft"); + } catch (Throwable t) { + Tester.check(false, "should have been softened: " + t); + } + + try { + new C().pretendsToThrow(); + } catch (IOException ioe) { + Tester.check(false, "bad IO"); + } + + Tester.check("m2-soft"); + Tester.check("around-m3"); + } +} + +class C { + public void throwIt() throws Throwable { + throw makeThrowable(); + } + + public void pretendsToThrow() throws IOException, ClassNotFoundException { + + } + + private Throwable makeThrowable() { + return new Exception("make me soft"); + } + + + public void m1() { + } + + public void m2() { + new File("___hi").getCanonicalPath(); + new FileInputStream("___bye"); + } + + public void m3() { + new FileInputStream("___bye"); + new File("___hi").getCanonicalPath(); + } +} + +aspect B { + declare soft: Exception: execution(* C.throwIt()); + + declare soft: ClassNotFoundException: call(* C.pretendsToThrow()); +} + + +aspect A { + declare soft: IOException: execution(* C.*(..)); + + void around(): execution(void C.m3()) { + try { + proceed(); + } catch (IOException ioe) { + Tester.note("around-m3"); + } + } +} |