Jason Weinstein wrote: > Thanks for the detailed response. Are there any statistics/performance > measurements available for AspectJ??? > > Also I "think" i now am understanding the difference between call and > execution. > > I think another way to think about it is with the code generated?? > > call() generates code in the context of the call while execution > generates code in the target of the call??? > > call() generates code in each place the adviced code is called where > execution only changes the original target method, or constructor, > e.g. the caller does not generate code.. Hi Jason, yes, you mostly got it .. it's exactly that way. As a consequence, Call gives a bit more control, cause you have access to both instances (the calling one and the called one), and also is the only good way of doing an around on a costructor and change the returned instance with another one (for example with a subclass, making a factory pattern out of "new X" calls).
As opposite, execution gives a bit less control, but changes one single point of your code. This means that ones your classes are woven, they can be used as a library in other projects without requiring them to weave their code. > >> >> QUESTION 2 >> >> What happens when a the original method does not throw an >> Exception but the advice throws an Exception?? Does the "throws >> Exception" get woven into the original Constructor (or Method)? I >> tested it and i guess you would just get an unhandled exception. >> This seems real bad and i guess is something to watch out for?? >> The "throws" exception is not weaved, it would be a breaking of the java rules. For example, I could have an interface defining a method that does not throw checked exceptions, then have a class implement this interface, then have an aspect adivicing this particular subclass. In that case, it would not be valid java anymore to declare the throws on this subclass. IIRC it's a bad practice (I was sure it was an error) for an advice to declare a checked exception that is not declared also on the adviced methods. Anyway, throwing an unchecked exception is not bad at all, instead there are a lot of advantages in using unchecked exceptions instead of checked ones, I mean in plain Java, not specifically in AOP or ApsectJ in particular. You can find a lot of articles about this, from both parties, especially search for "does java needs checked exceptions", I can't remember the author but it's a good source of informations on this matter. AspectJ has its own unchecked exception, and provide a way to "soften" existing code to use unchecked exceptions instead of checked ones where needed, which I found very very very useful in a large number of situations. Hope this helps clarify, Simone -- Simone Gianni CEO Semeru s.r.l. Apache Committer http://www.simonegianni.it/ _______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
