String signature, String[] exceptions) {
LOGGER.debug(Constants.LOG_ENTRY, "visitMethod", new Object[] { access,
name, desc, signature, exceptions });
Method currentMethod = new Method(name, desc);
getKnownMethods().add(currentMethod);
MethodVisitor methodVisitorToReturn = null;
// Only weave "real" instance methods. Not constructors, initializers or
// compiler generated ones.
if ((access & (ACC_STATIC | ACC_PRIVATE | ACC_SYNTHETIC | ACC_ABSTRACT
| ACC_NATIVE | ACC_BRIDGE)) == 0 && !!!name.equals("<init>") &&
!!!name.equals("<clinit>")) {
// found a method we should weave
//Create a field name and store it for later
String methodStaticFieldName = "methodField" + getSanitizedUUIDString();
transformedMethods.put(methodStaticFieldName, new TypeMethod(
getDeclaringTypeForCurrentMethod(), currentMethod));
// Surround the MethodVisitor with our weaver so we can manipulate the code
methodVisitorToReturn = getWeavingMethodVisitor(access, name, desc,
signature, exceptions, currentMethod, methodStaticFieldName);
} else if (name.equals("<clinit>")){
//there is an existing clinit method, change the fields we use
//to write our init code to static_init_UUID instead
staticInitMethod = new Method("static_init_" + UU_ID, Type.VOID_TYPE, NO_ARGS);
staticInitMethodFlags = staticInitMethodFlags | ACC_FINAL;
methodVisitorToReturn = new AdviceAdapter(cv.visitMethod(access, name, desc, signature,
exceptions), access, name, desc){
@Override
protected void onMethodEnter()
{
//add into the <clinit> a call to our synthetic static_init_UUID
invokeStatic(typeBeingWoven, staticInitMethod);
super.onMethodEnter();
}
};
} else {
if(currentMethod.getArgumentTypes().length == 0 && name.equals("<init>"))
hasNoArgsConstructor = true;
//This isn't a method we want to weave, so just get the default visitor
methodVisitorToReturn = cv.visitMethod(access, name, desc, signature,
exceptions);
}