//AXm_joinPointIndex =
// TransformationUtil.getJoinPointIndex(klass.getCtClass()); //TODO
// 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(MethodCall methodCall) throws CannotCompileException {
// AW-228, super.callSomething(..) is not a valid join point
if (methodCall.isSuper()) {
return;
}
try {
CtBehavior where;
try {
where = methodCall.where();
} catch (RuntimeException e) {
// <clinit> access leads to a bug in Javassist
where = ctClass.getClassInitializer();
}
// filter caller methods
if (methodFilterCaller(where)) {
return;
}
// get the callee method name, signature and class name
CtMethod calleeMethod = methodCall.getMethod();
String calleeClassName = methodCall.getClassName();
// filter callee classes
if (!definition.inIncludePackage(calleeClassName)) {
return;
}
// filter callee methods
if (methodFilterCallee(calleeMethod)) {
return;
}
JavassistClassInfoRepository classInfoRepository = JavassistClassInfoRepository
.getRepository(context.getLoader());
// TODO: callee side class info is NOT used, make use of it
ClassInfo calleeSideClassInfo = classInfoRepository.getClassInfo(calleeClassName);
if (calleeSideClassInfo == null) {
calleeSideClassInfo = JavassistClassInfo.getClassInfo(ctClass.getClassPool().get(
calleeClassName), context.getLoader());
}
// create the caller method info, used for 'within' and
// 'withincode'
MemberInfo withinMemberInfo = null;
if (where instanceof CtMethod) {
withinMemberInfo = JavassistMethodInfo.getMethodInfo((CtMethod) where, context.getLoader());
} else if (where instanceof CtConstructor) {
withinMemberInfo = JavassistConstructorInfo.getConstructorInfo(
(CtConstructor) where,
context.getLoader());
}
// create the callee method info
MethodInfo calleeSideMethodInfo = JavassistMethodInfo.getMethodInfo(
methodCall.getMethod(),
context.getLoader());
ExpressionContext ctx = new ExpressionContext(
PointcutType.CALL,
calleeSideMethodInfo,
withinMemberInfo);
if (definition.hasPointcut(ctx) || definition.hasCflowPointcut(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;