|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
after advice and try catch statementHi
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. Thanks Anthony |
|
|
Re: after advice and try catch statementantofmr 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@... https://dev.eclipse.org/mailman/listinfo/aspectj-dev |
|
|
Re: after advice and try catch statementIf you use the 'after returning' advice (instead of the plain 'after'), you should be able to avoid the try/catch block.
-Ramnivas
2009/7/1 Holger Hoffstätte <holger.hoffstaette@...>
_______________________________________________ aspectj-dev mailing list aspectj-dev@... https://dev.eclipse.org/mailman/listinfo/aspectj-dev |
|
|
Re: after advice and try catch statementHi
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
|
|
|
Re: after advice and try catch statementIf advice is written correctly, it won't interfere with your exception handling. Generally speaking, you shouldn't worry about how and where AspectJ adds code. Instead, think about the language semantics.
If you experience problems, you can show the code and the expected vs. observed behavior. -Ramnivas
On Wed, Jul 1, 2009 at 10:34 AM, antofmr <Anthony.Conneely@...> wrote:
_______________________________________________ aspectj-dev mailing list aspectj-dev@... https://dev.eclipse.org/mailman/listinfo/aspectj-dev |
| Free embeddable forum powered by Nabble | Forum Help |