Re: Is return statement ignored in advice?
Gregor Kiczales <[email protected]> Fri, 17 Aug 2007 10:35:27 -0700
| Newsgroups | gmane.comp.programming.aspect.general |
|---|---|
| Message-ID | <C2EB2A6F.3B3ED%[email protected]> |
The return statement returns from the advice execution. In the case of before and the three afters, which run before/after the join point, this doesn't affect the execution of what would have happened. In the case of around, which is around the join point, return can be used to skip a proceed that appears in the advice body. In my experience, confusion about this comes up when people are thinking about AspectJ advice using a 'pre-processor' or 'code injection' semantic model. If you think about the text of the before advice being COPIED into an advised method for example, you can come to think that a return in before advice would be like a return in the method itself. This is one of the many problems with thinking about AspectJ using a pre-processor semantics. Instead, just consider the semantics to be that the "advice EXECUTE before/after/around the join point". They aren't copied in, you can just count on them being run. On 8/17/07 9:50 AM, "Mike Mortensen" <[email protected]> wrote: > I'm wondering if you expected a 'return' in the advice to return > from the 'advised' method, but a return in the advice just exits > the advice and the method executes. > > If you want to change method execution, you have to create 'around advice' > and not call proceed... > > Hopefully I correctly guessed your intention... :-) > -Mike > > >> I doubt that this is the case. If so, it's certainly a bug. I think >> you must be misinterpreting something. Can you give an example? >> >> Eric >> >> On 17/08/07, chuan Zhao <[email protected]> wrote: >> >> >>> Hi All, >>> >>> I found that in AspectJ, if I put a return statement in an advice, it will >>> not affect the execution of program. Is return just ignored in any advice? I >>> couldn't find any explanation in AspectJ documentation. Could anyone give >>> some answer to this? >>> >>> Thanks, >>> Chuan >>> >>> _______________________________________________ >>> discuss mailing list - [email protected] >>> >>> To unsubscribe and change options, go to: >>> http://aosd.net/mailman/listinfo/discuss_aosd.net >>> >>> Check out the AOSD.net Wiki: http://aosd.net/wiki >>> >>> >>> >> >> >> >> > > > _______________________________________________ > discuss mailing list - [email protected] > > To unsubscribe and change options, go to: > http://aosd.net/mailman/listinfo/discuss_aosd.net > > Check out the AOSD.net Wiki: http://aosd.net/wiki _______________________________________________ discuss mailing list - [email protected] To unsubscribe and change options, go to: http://aosd.net/mailman/listinfo/discuss_aosd.net Check out the AOSD.net Wiki: http://aosd.net/wiki