Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] after advice and try catch statement

Hi 

Thanks for your help I think I understand your answer could you please just
confirm it for me. In my method I catch 3 types of custome exception. Info
on the exception is gathered and the exception is thrown back up to the
calling method. The code I insert into the end of the method makes a call to
an API.

My understanding from your explanation is that the catch clause added by the
AspectJ compiler is there to catch any possible exception thrown in the
method and to pass this exception to the calling class using the super type
Throwable. The code I insert is added in this catch clause and also as the
last line in the method so that the call will be made to the API if an
exception is thrown or not.

My main concern is that the try catch clause added by the aspectj will stop
my custome exception been passed up to the calling class.

One final query I have, is it possible to no if the execution of the method
has entered the aspectj's catch clause ie. is it possible to insert a
pointcut for the catch clause introduced by the aspect. I want to set a flag
to indicate that the method completed sucessfully. 

Thanks again for your Help

Anthony



Holger Hoffstätte-4 wrote:
> 
> antofmr wrote:
>> I am using the after advice to insert some code into the end of a method.
>> When I de-compile the method I see that the aspectj compiler has inserted
>> a
>> try catch statement into the method. The try is the very first line and
>> the
>> catch is at the end of the method. Is there anyway of inserting the code
>> without this try catch clause been added or is this the only way that the
>> after advice works.
> 
> This is just how "after" must work by necessity, otherwise you would end
> up having to specify a potentially limitless number of additional
> conditions.
> If you want to control the execution of your advice at the end of the
> method, use around/proceed and then decide what to do.
> 
> -h
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
> 
> 

-- 
View this message in context: http://www.nabble.com/after-advice-and-try-catch-statement-tp24288917p24290881.html
Sent from the AspectJ - dev mailing list archive at Nabble.com.



Back to the top