[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] throwing exceptions from an advice
|
My question is about the "Advice and checked exceptions" section on page 78
of the AspectJ Programming Guide.
The first sentence mentions that "An advice declaration must include a
throws clause listing the checked exceptions the body may throw." (emphasis
on "An advice"). However, the quick reference contained in Table A.4 (p. 64)
shows that a throws clause can only be present in an around advice. I first
wondered what part was the correct one and I came up with the following code
which shows that actually any kind of advice may have a throws clause.
public aspect Test {
int i;
pointcut h() :
get(int Test.i);
before() throws java.io.FileNotFoundException : h(){
throw new java.io.FileNotFoundException();
}
after() throws java.io.FileNotFoundException : h(){
throw new java.io.FileNotFoundException();
}
void around() throws java.io.FileNotFoundException : h(){
throw new java.io.FileNotFoundException();
}
}
Moreover, the above code is in conflict with what is mentioned on pages
78-79 about the fact that it is not possible for get join points to throw a
FileNotFoundException (or any checked exception for that matter).
Could someone shed some light on this?
Thanks :)
Val