summaryrefslogtreecommitdiffstats
path: root/tests/bugs152/pr129282/ExceptionHandler.aj
blob: 3ff3f47e20314dbe72f5b5f742df494f127cb5cf (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
// with the exception handler, the advice isn't actually throwing the
// exception for the method - therefore, expect warnings when the methods
// don't throw the exception themselves.
public aspect ExceptionHandler {

	pointcut p() : handler(*);
	
	before() throws MyException : p() {
		throw new MyException();
	}
	
	
}

class C {
	
	public void method1() {
		try {
			new C().throwingMethod();
			new C().throwingMethod2();
		} catch (MyException e) {
			e.printStackTrace();
		}
	}
	
	// dont want 'declared exception not actually thrown'
	// warning for this method because it's throwing it
	public void throwingMethod() throws MyException {
		throw new MyException();
	}
	
	// do want 'declared exception not actually thrown'
	// warning because it doesn't throw it
	public void throwingMethod2() throws MyException {
	}
}

class MyException extends Exception {
}