Search in sources :

Example 6 with Type

use of org.objectweb.asm.Type in project cglib by cglib.

the class Enhancer method emitCommonNewInstance.

private void emitCommonNewInstance(CodeEmitter e) {
    Type thisType = getThisType(e);
    e.new_instance(thisType);
    e.dup();
    e.invoke_constructor(thisType);
    e.aconst_null();
    e.invoke_static(thisType, SET_THREAD_CALLBACKS);
    e.return_value();
    e.end_method();
}
Also used : Type(org.objectweb.asm.Type)

Example 7 with Type

use of org.objectweb.asm.Type in project cglib by cglib.

the class Enhancer method emitNewInstanceMultiarg.

private void emitNewInstanceMultiarg(ClassEmitter ce, List constructors) {
    final CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, MULTIARG_NEW_INSTANCE, null);
    final Type thisType = getThisType(e);
    e.load_arg(2);
    e.invoke_static(thisType, SET_THREAD_CALLBACKS);
    e.new_instance(thisType);
    e.dup();
    e.load_arg(0);
    EmitUtils.constructor_switch(e, constructors, new ObjectSwitchCallback() {

        public void processCase(Object key, Label end) {
            MethodInfo constructor = (MethodInfo) key;
            Type[] types = constructor.getSignature().getArgumentTypes();
            for (int i = 0; i < types.length; i++) {
                e.load_arg(1);
                e.push(i);
                e.aaload();
                e.unbox(types[i]);
            }
            e.invoke_constructor(thisType, constructor.getSignature());
            e.goTo(end);
        }

        public void processDefault() {
            e.throw_exception(ILLEGAL_ARGUMENT_EXCEPTION, "Constructor not found");
        }
    });
    e.aconst_null();
    e.invoke_static(thisType, SET_THREAD_CALLBACKS);
    e.return_value();
    e.end_method();
}
Also used : Type(org.objectweb.asm.Type) Label(org.objectweb.asm.Label)

Example 8 with Type

use of org.objectweb.asm.Type in project cglib by cglib.

the class Enhancer method emitNewInstanceCallbacks.

private void emitNewInstanceCallbacks(ClassEmitter ce) {
    CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, NEW_INSTANCE, null);
    Type thisType = getThisType(e);
    e.load_arg(0);
    e.invoke_static(thisType, SET_THREAD_CALLBACKS);
    emitCommonNewInstance(e);
}
Also used : Type(org.objectweb.asm.Type)

Example 9 with Type

use of org.objectweb.asm.Type in project cglib by cglib.

the class FieldProviderTransformer method initFieldProvider.

private void initFieldProvider(String[] names) {
    CodeEmitter e = getStaticHook();
    EmitUtils.push_object(e, names);
    e.putstatic(getClassType(), FIELD_NAMES, Constants.TYPE_STRING_ARRAY);
    e.push(names.length);
    e.newarray(Constants.TYPE_CLASS);
    e.dup();
    for (int i = 0; i < names.length; i++) {
        e.dup();
        e.push(i);
        Type type = (Type) fields.get(names[i]);
        EmitUtils.load_class(e, type);
        e.aastore();
    }
    e.putstatic(getClassType(), FIELD_TYPES, Constants.TYPE_CLASS_ARRAY);
}
Also used : Type(org.objectweb.asm.Type)

Example 10 with Type

use of org.objectweb.asm.Type in project cglib by cglib.

the class InterceptFieldTransformer method begin_method.

public CodeEmitter begin_method(int access, Signature sig, Type[] exceptions) {
    return new CodeEmitter(super.begin_method(access, sig, exceptions)) {

        public void visitFieldInsn(int opcode, String owner, String name, String desc) {
            Type towner = TypeUtils.fromInternalName(owner);
            switch(opcode) {
                case Constants.GETFIELD:
                    if (filter.acceptRead(towner, name)) {
                        helper(towner, readMethodSig(name, desc));
                        return;
                    }
                    break;
                case Constants.PUTFIELD:
                    if (filter.acceptWrite(towner, name)) {
                        helper(towner, writeMethodSig(name, desc));
                        return;
                    }
                    break;
            }
            super.visitFieldInsn(opcode, owner, name, desc);
        }

        private void helper(Type owner, Signature sig) {
            invoke_virtual(owner, sig);
        }
    };
}
Also used : Type(org.objectweb.asm.Type)

Aggregations

Type (org.objectweb.asm.Type)151 MethodVisitor (org.objectweb.asm.MethodVisitor)33 Label (org.objectweb.asm.Label)21 Method (org.objectweb.asm.commons.Method)16 GeneratorAdapter (org.objectweb.asm.commons.GeneratorAdapter)14 ClassWriter (org.objectweb.asm.ClassWriter)13 ArrayList (java.util.ArrayList)11 ClassReader (org.objectweb.asm.ClassReader)10 Method (java.lang.reflect.Method)9 AnnotationVisitor (org.objectweb.asm.AnnotationVisitor)9 ClassVisitor (org.objectweb.asm.ClassVisitor)9 PropertyAccessorType (org.gradle.internal.reflect.PropertyAccessorType)7 ModelType (org.gradle.model.internal.type.ModelType)7 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)6 MethodType (java.lang.invoke.MethodType)6 List (java.util.List)6 VarInsnNode (org.objectweb.asm.tree.VarInsnNode)5 InterceptorType (com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorType)4 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4