Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Question about aspectj weaver

Thank you for your answer Jim.

I was all the time in misbelief that aspectj weaver is using ASM and
StructureModelUtil (used by GUIs for Outline Views) for weaving the class
Files.

I hope I've interpreted your answer correctly:
The aspectj weaver is working with pointcuts declared as .class attributes
and advices declared as common java method following special naming
convention.

cheers!
	Ivica

On Fri, Aug 08, 2003 at 02:30:36PM -0700, Jim Hugunin wrote:
> Ivica Aracic wrote:
> >I have a question about the aspectj weaver:
> >What does the weaver take as input?
> >How does it know where to insert the advices?
> 
> This question deserves a paper to answer it.  For now, you'll have to 
> settle for the following short answer.
> 
> Each piece of advice in an aspect is associated with a pointcut.  This 
> pointcut is stored in an attribute on the methods corresponding to each 
> piece of advice.  Before weaving, all of these pieces of advice are 
> gathered into one large list.
> 
> Each .class file is woven independently.  A .class file is woven by the 
> following steps:
> 
> 1. Collect all of the joinpoint shadows in the .class file.  For every 
> dynamic joinpoint in the AspectJ language model, there is a 
> corresponding static shadow of that joinpoint in the bytecode.  For 
> example, every method call joinpoint has an INVOKE bytecode as its 
> static shadow.  Some joinpoints (such as initialization) have much more 
> complicated static shadows.
> 
> 2. Each piece of advice is matched to each static shadow.  There are 
> three results possible from this match.
> 
> a. Never matches -- in which case nothing is done to the shadow
> b. Always matches -- in which case the advice is woven into this 
> joinpoint shadow
> c. Sometimes matches -- in which case the advice is woven into the 
> shadow along with the minimal dynamic tests to determine if any 
> particular joinpoint in the actual running program matches the advice. 
> The simplest example of sometimes matches is when the pointcut uses 
> if(test()).
> 
> 3. If any advice matched any static shadows in the .class file, then the 
> transformed .class file is written out, otherwise it is left unchanged.
> 
> See org.aspectj.weaver.bcel.BcelClassWeaver and BcelShadow for the two 
> primary classes involved in this process.
> 
> Note: This explanation ignores the implementations of inter-type 
> declarations completely.  It also ignores performance optimizations such 
> as fast-match that speed up the weaving process.
> 
> -Jim
> 
> 
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-dev

-- 
Ivica Aracic
ICQ 58372826 (macross)
http://www.bytelords.de/



Back to the top