* even when one single pointcut has one common element (which can be a side-effect of DNF rewriting).
*/
private void rewritePointcuts(List<ShadowMunger> shadowMungers) {
PointcutRewriter rewriter = new PointcutRewriter();
for (ShadowMunger munger : shadowMungers) {
Pointcut p = munger.getPointcut();
Pointcut newP = rewriter.rewrite(p);
// validateBindings now whilst we still have around the pointcut
// that resembles what the user actually wrote in their program
// text.
if (munger instanceof Advice) {
Advice advice = (Advice) munger;
if (advice.getSignature() != null) {
final int numFormals;
final String names[];
// If the advice is being concretized in a @AJ aspect *and*
// the advice was declared in
// an @AJ aspect (it could have been inherited from a code
// style aspect) then
// evaluate the alternative set of formals. pr125699
if ((advice.getConcreteAspect().isAnnotationStyleAspect() && advice.getDeclaringAspect() != null && advice
.getDeclaringAspect().resolve(world).isAnnotationStyleAspect())
|| advice.isAnnotationStyle()) {
numFormals = advice.getBaseParameterCount();
int numArgs = advice.getSignature().getParameterTypes().length;
if (numFormals > 0) {
names = advice.getSignature().getParameterNames(world);
validateBindings(newP, p, numArgs, names);
}
} else {
numFormals = advice.getBaseParameterCount();
if (numFormals > 0) {
names = advice.getBaseParameterNames(world);
validateBindings(newP, p, numFormals, names);
}
}
}
}
newP.m_ignoreUnboundBindingForNames = p.m_ignoreUnboundBindingForNames;
munger.setPointcut(newP);
}
// now that we have optimized individual pointcuts, optimize
// across the set of pointcuts....
// Use a map from key based on pc equality, to value based on
// pc identity.
Map/* <Pointcut,Pointcut> */<Pointcut, Pointcut> pcMap = new HashMap<Pointcut, Pointcut>();
for (Iterator iter = shadowMungers.iterator(); iter.hasNext();) {
ShadowMunger munger = (ShadowMunger) iter.next();
Pointcut p = munger.getPointcut();
Pointcut newP = shareEntriesFromMap(p, pcMap);
newP.m_ignoreUnboundBindingForNames = p.m_ignoreUnboundBindingForNames;
munger.setPointcut(newP);
}
}