Search in sources :

Example 36 with MethodVisitor

use of jodd.asm5.MethodVisitor in project jodd by oblac.

the class MethodFinder method visitMethod.

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    if (paramExtractor != null) {
        // method already found, skip all further methods
        return null;
    }
    if (!name.equals(methodName)) {
        // different method
        return null;
    }
    Type[] argumentTypes = Type.getArgumentTypes(desc);
    int dwordsCount = 0;
    for (Type t : argumentTypes) {
        if (t.getClassName().equals(TYPE_LONG) || t.getClassName().equals(TYPE_DOUBLE)) {
            dwordsCount++;
        }
    }
    int paramCount = argumentTypes.length;
    if (paramCount != this.parameterTypes.length) {
        // different number of params
        return null;
    }
    for (int i = 0; i < argumentTypes.length; i++) {
        if (!isEqualTypeName(argumentTypes[i], this.parameterTypes[i])) {
            // wrong param types
            return null;
        }
    }
    this.paramExtractor = new ParamExtractor((Modifier.isStatic(access) ? 0 : 1), argumentTypes.length + dwordsCount);
    return paramExtractor;
}
Also used : Type(jodd.asm5.Type)

Aggregations

MethodVisitor (org.apache.xbean.asm5.MethodVisitor)28 MethodVisitor (jodd.asm5.MethodVisitor)6 ClassWriter (org.apache.xbean.asm5.ClassWriter)6 Label (org.apache.xbean.asm5.Label)5 Method (java.lang.reflect.Method)3 ArrayList (java.util.ArrayList)2 Arrays.asList (java.util.Arrays.asList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 EmptyClassVisitor (jodd.asm.EmptyClassVisitor)2 EmptyMethodVisitor (jodd.asm.EmptyMethodVisitor)2 Label (jodd.asm5.Label)2 Field (java.lang.reflect.Field)1 MethodAdapter (jodd.asm.MethodAdapter)1 FieldVisitor (jodd.asm5.FieldVisitor)1 Type (jodd.asm5.Type)1 ProxettaException (jodd.proxetta.ProxettaException)1 Type (org.apache.xbean.asm5.Type)1