//AXm_joinPointIndex =
// TransformationUtil.getJoinPointIndex(klass.getCtClass()); //TODO is
// not thread safe / reentrant
for (Iterator it = definitions.iterator(); it.hasNext();) {
final SystemDefinition definition = (SystemDefinition) it.next();
final CtClass ctClass = klass.getCtClass();
ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
if (classFilter(definition, new ExpressionContext(PointcutType.CALL, null, classInfo), ctClass)) {
continue;
}
ctClass.instrument(new ExprEditor() {
public void edit(NewExpr newExpr) throws CannotCompileException {
try {
CtBehavior where = null;
try {
where = newExpr.where();
} catch (RuntimeException e) {
// <clinit> access leads to a bug in Javassist
where = ctClass.getClassInitializer();
}
// filter caller methods
if (methodFilterCaller(where)) {
return;
}
CtConstructor ctConstructor = newExpr.getConstructor();
String calleeClassName = newExpr.getClassName();
// filter callee classes
if (!definition.inIncludePackage(calleeClassName)) {
return;
}
// filter the constructors
if (constructorFilter(ctConstructor)) {
return;
}
// create the caller method info
MemberInfo withinMethodInfo = null;
if (where instanceof CtMethod) {
withinMethodInfo = JavassistMethodInfo.getMethodInfo((CtMethod) where, context.getLoader());
} else if (where instanceof CtConstructor) {
withinMethodInfo = JavassistConstructorInfo.getConstructorInfo(
(CtConstructor) where,
context.getLoader());
}
// create the constructor info
CtConstructor constructor = newExpr.getConstructor();
ConstructorInfo calleeSideConstructorInfo = JavassistConstructorInfo.getConstructorInfo(
constructor,
context.getLoader());
ExpressionContext ctx = new ExpressionContext(
PointcutType.CALL,
calleeSideConstructorInfo,
withinMethodInfo);
// is this a caller side method pointcut?
if (definition.hasPointcut(ctx)) {
// check the callee class is not the same as target
// class, if that is the case
// then we have have class loaded and set in the
// ___AW_clazz already
String declaringClassMethodName = TransformationConstants.STATIC_CLASS_FIELD;