aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/PR318.java
blob: da43d463df0dc154fe823dbbe98f7e69105eb2d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
public class PR318 {
    public static void main(String[] args) {
        new PR318().realMain(args);
    }
    public void realMain(String[] args) {
        Bar.bar();
        org.aspectj.testing.Tester.check(caught, "Exception wasn't caught");
    }
    static boolean caught = false;
    
}

class Foo {
    static void foo () throws Exception {
	throw new IllegalArgumentException("foo!");
    }
}

class Bar {
    static void bar () {
	try {
	    Foo.foo();
	} catch (Exception e) {
	}
    }
}

aspect A {
    before (Exception e): handler(Exception) && args(e) {
	if (e instanceof IllegalArgumentException) {
            PR318.caught = true;
	}
    }
}