[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] throwing exceptions from an advice
|
It looks to me like you found two bugs.
- All advice can have throws clauses declaring exceptions.
The quick reference would be wrong to state otherwise;
thanks for finding that doc bug.
- The compiler should emit an error whenever advice is declared to
throw an exception which is not permitted to be thrown by a
join point. So your code looks like a bug in the compiler to me.
Thanks for the close reading and clear statement!
You're welcome to submit these to http://eclipse.org/bugs;
they might otherwise be neglected in the run-up to 1.1.
Wes
Valentin Crettaz wrote:
>
> 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
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users