aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/AdviceThrowsCf.java
diff options
context:
space:
mode:
authorwisberg <wisberg>2002-12-16 18:51:06 +0000
committerwisberg <wisberg>2002-12-16 18:51:06 +0000
commit144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch)
treeb12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/AdviceThrowsCf.java
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/new/AdviceThrowsCf.java')
-rw-r--r--tests/new/AdviceThrowsCf.java80
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/new/AdviceThrowsCf.java b/tests/new/AdviceThrowsCf.java
new file mode 100644
index 000000000..f8564d979
--- /dev/null
+++ b/tests/new/AdviceThrowsCf.java
@@ -0,0 +1,80 @@
+import org.aspectj.testing.Tester;
+import java.io.IOException;
+
+public class AdviceThrowsCf {
+ public static void main(String[] args) {
+ try {
+ new C().m1();
+ Tester.checkFailed("m1");
+ } catch (CheckedExc ce) {
+ Tester.checkEqual("b1", ce.getMessage(), "m1");
+ }
+ try {
+ new C().m2();
+ Tester.checkFailed("m2");
+ } catch (UncheckedExc ce) {
+ Tester.checkEqual("b3", ce.getMessage(), "m2");
+ }
+ try {
+ new C().m3();
+ Tester.checkFailed("m3");
+ } catch (CheckedExc ce) {
+ Tester.checkEqual("b1", ce.getMessage(), "m3");
+ } catch (Exception e) {
+ Tester.checkFailed("IOException");
+ System.out.println("m3: " + e);
+ }
+ try {
+ new C().m4();
+ Tester.checkFailed("m4");
+ } catch (UncheckedExc ce) {
+ Tester.checkEqual("b3", ce.getMessage(), "m4");
+ }
+ }
+
+
+}
+
+class CheckedExc extends Exception {
+ CheckedExc(String m) { super(m); }
+}
+
+class UncheckedExc extends RuntimeException {
+ UncheckedExc(String m) { super(m); }
+}
+
+
+class C {
+ int x=0;
+ public void m1() throws CheckedExc {
+ x += 1;
+ }
+
+ public void m2() throws UncheckedExc {
+ }
+
+ public void m3() throws IOException, CheckedExc {
+ }
+
+ public void m4() {
+ }
+}
+
+aspect A {
+ pointcut canThrowChecked(): call(* C.m1()) || call(* C.m3());
+ pointcut canThrowChecked1(): call(* C.m*() throws CheckedExc);
+
+ pointcut canThrowUnchecked(): call(* C.m*());
+
+
+ before() throws CheckedExc: canThrowUnchecked() { // ERR: m2 and m4
+ throw new CheckedExc("b1");
+ }
+
+ before() throws CheckedExc: get(int C.x) { //ERR: all gets
+ }
+ before() throws CheckedExc: set(int C.x) { //ERR: all sets
+ }
+ before() throws CheckedExc: staticinitialization(C) { //ERR: can't throw
+ }
+}