mirror of
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-09-03 05:54:57 +02:00
34 lines
752 B
Plaintext
34 lines
752 B
Plaintext
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{
|
|
}
|
|
|
|
}
|