Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Is there a common syntax for a compile time "if"pointcut?

Hi Alex, 

From: Alexandre Vasseur <avasseur@xxxxxxxxx>
Subject: Re: [aspectj-users] Is there a common syntax for a compile time	"if"pointcut?
Date: Fri, 3 Jun 2005 13:53:57 +0200

> Eric, it looks like SCoPE is an ABC extension.

Yes, SCoPE is an ABC extension.  Thanks for the clarification, and
thank the ABC team for their great system!

> Hidehiko, I am interested by some details.
> As far as I can see I can write in SCoPE:
> "... && if(thisJoinPointStaticPart.getSignature().getDeclaringType()
> instanceof Serializable)"
> 
> This means I introduce a dependancy on the getDeclaringType() that is
> to return a Class instance - the currently beeing weaved or compiled
> class - say X.
> 
> That sounds surprising to me if you really manage to do that since:
> - if you are compiling the class X, how would you have it loaded in
> the VM, aside, in which VM (there might be issue with incremental
> builds). You are precisely compiling it so that should somehow be an
> invalid class thus impossible to compile in theory.
> - if you are weaving the class X (say binary weave), how would you
> have it loaded in the VM as well - this somehow means the bytecode is
> not yet ready or that you may have a half weaved version.

That's a very good point.  SCoPE's semantics is to give runtime
context; i.e., the class X has the same property to the one used at
runtime.

SCoPE achieves this semantics by actually compiling the whole program
first, then by evaluates the conditions with loading those compiled
classes.  With results of evaluation, the second step optimizes the
code by removing dynamic conditions from if pointcuts.  (So we would
perhaps need further techniques for supporing load-time weaving.)

> The use case is very appealing, and I had given it some thoughts in
> AspectWerkz. I would have gone for a different implementation, where I
> would have exposed a "wif" (weave time if) pointcut, that could then
> expose a different abstraction than JoinPoint (based on
> java.lang.reflect) to rely on the compile/weave time structure we have
> behind anyway (thus no need to load any curently beeing compiled
> class, but the syntax would have been something like
> "... && wif(thisShadow.....)" where thisShadow is slightly different
> from what is exposed in JoinPointStaticPart.
> Using that would immediately allow ones to implement hasField style
> pointcuts that are purely static (though ITD can comes into the game).
> In that case I would have to still evaluate the little syntax you
> would use in some context but I would definitely not need to actually
> load the class beeing weaved/compiled.

I can understand this approach would be easier to be implemented.
Actually, this approach has some similarity with systems like Josh
(http://www.csg.is.titech.ac.jp/paper/chiba-aosd2004.pdf).  A possible
advantage in our approach is that the programmer does not have to
learn new APIs, and the programmer can share the conditions between if
pointcut and runtime code.  If you have a somewhat complicated
analysis:

 boolean isSerializable(Joinpoint jp) {
  return thisJoinPointStaticPart.getSignature().getDeclaringType().
	 instanceof Serializable;
 }

then you can use it in if-pointcut without runtime overhead, and can
also use it in the body of advice or method.  This would help
programmers in some situation.

> Could you explain me some more the details of your impl. in SCoPE, or
> perhaps the pointcut I gave will only be evaluated at runtime ?
> 
> Alex

I hope this answered your question.

Hidehiko

> 
> 
> 
> On 6/3/05, Eric Bodden <eric@xxxxxxxxx> wrote:
> > 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> > 
> > Just for your information: abc (www.aspectbench.org) can do so as
> > well. It even allows for the use of cflow under certain circumstances
> > IIRC.
> > 
> > Eric
> > 
> > Hidehiko Masuhara wrote:
> > > Hi Scott,
> > >
> > > You might be interested in our SCoPE compiler, which we
> > > coincidentally just have released.  It directly supports what you
> > > want to do---"if"
> > > pointcut can be used with declare warning/error when the conditions
> > > are static.
> > 
> > 
> > - --
> > Eric Bodden
> > Chair I2 for Programming Languages and Program Analysis
> > RWTH Aachen University
> > 
> > -----BEGIN PGP SIGNATURE-----
> > Version: PGP 8.0.3
> > 
> > iQA/AwUBQqA9EcwiFCm7RlWCEQJCyACguQrGEKTdDf8+dcvXcZSLD2kYQpQAn0cV
> > 2mTW0TWQw9gzjAlXOwBMs1lv
> > =2jKM
> > -----END PGP SIGNATURE-----
> > 
> > 
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top