blob: 45224f7a349ef1b8a8e7e980ae35edbcf22c4533 (
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
|
import java.sql.SQLException;
public aspect MethodExecution {
pointcut pc() : execution(public * C.shouldntThrow(..));
Object around() throws SQLException :pc(){
throw new SQLException();
}
pointcut pc2() : execution(public * C.needsToThrow(..));
// C.needsToThrow still needs to throw the exception because
// this advice isn't doing anything with exceptions
before() : pc2() {
}
}
class C {
// don't want the "declared exception is not actually
// thrown" message because around advice is affecting
// this method
public void shouldntThrow() throws SQLException {
}
// do want the "declared exception is not actually
// thrown" message to appear for this method
public void needsToThrow() throws SQLException{
}
}
|