aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs151/pr122742/AfterThrowingTest.java
blob: 449893e371892315bc1d31f07a259a3bfe55902f (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;

@Aspect
public class AfterThrowingTest {

	public static void main(String[] args) {
		try {
			new B().start();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	// include "JoinPoint" in the argument list
	@AfterThrowing(pointcut = "execution(public void B.start())", throwing = "ex")
	public void handleExceptionJP(JoinPoint jp, Exception ex) {	
	}

	// include "JoinPoint.StaticPart" in the argument list
	@AfterThrowing(pointcut = "execution(public void B.start())", throwing = "ex")
	public void handleExceptionJPSP(JoinPoint.StaticPart jp, Exception ex) {	
	}
	
	// include "JoinPoint.EnclosingStaticPart" in the argument list
	@AfterThrowing(pointcut = "execution(public void B.start())", throwing = "ex")
	public void handleExceptionJPESP(JoinPoint.EnclosingStaticPart jp, Exception ex) {	
	}
	
	// include "JoinPoint" and "JoinPoint.EnclosingStaticPart" in the argument list
	@AfterThrowing(pointcut = "execution(public void B.start())", throwing = "ex")
	public void handleExceptionJPESP(JoinPoint jp1, JoinPoint.EnclosingStaticPart jp, Exception ex) {	
	}
	
	// make sure it still works if "JoinPoint" is second on the argument list
	@AfterThrowing(pointcut = "execution(public void B.start())", throwing = "ex")
	public void handleExceptionJP2(JoinPoint jp, Exception ex) {	
	}
}

class B implements I {
	public void start() throws Exception {
		throw new IllegalArgumentException();
	}	
}

interface I {
	public void start() throws Exception;
}