for (Iterator it = m_definitions.iterator(); it.hasNext();) {
final SystemDefinition definition = (SystemDefinition)it.next();
final CtClass ctClass = klass.getCtClass();
ClassMetaData classMetaData = JavassistMetaDataMaker.createClassMetaData(ctClass);
// filter caller classes
if (classFilter(definition, classMetaData, ctClass)) {
return;
}
ctClass.instrument(
new ExprEditor() {
public void edit(MethodCall methodCall) throws CannotCompileException {
try {
CtBehavior where = null;
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;
}
// create the class meta-data
ClassMetaData calleeSideClassMetaData;
try {
calleeSideClassMetaData =
JavassistMetaDataMaker.createClassMetaData(
context.getClassPool().get(calleeClassName)
);