Search in sources :

Example 61 with Method

use of org.objectweb.asm.commons.Method in project evosuite by EvoSuite.

the class StubClassVisitor method createMethod.

/**
 * Stubbed methods forward the query to the central Stubs class
 * and return whatever that class tells it to return
 *
 * @param mg
 * @param m
 */
private void createMethod(GeneratorAdapter mg, Method m) {
    String methodName = "getReturnValue" + getTypeName(m.getReturnType());
    String desc = "(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)" + getReturnTypeDesc(m.getReturnType());
    mg.push(className);
    mg.push(m.getName() + m.getDescriptor());
    mg.loadArgArray();
    Type owner = Type.getType(PackageInfo.getNameWithSlash(Stubs.class));
    Method method = new Method(methodName, desc);
    mg.invokeStatic(owner, method);
    insertReturnCast(mg, m);
    mg.returnValue();
    mg.endMethod();
}
Also used : Type(org.objectweb.asm.Type) Method(org.objectweb.asm.commons.Method)

Example 62 with Method

use of org.objectweb.asm.commons.Method in project Payara by payara.

the class EjbOptionalIntfGenerator method generateBeanMethod.

private static void generateBeanMethod(ClassVisitor cv, String subClassName, java.lang.reflect.Method m, Class delegateClass) {
    String methodName = m.getName();
    Type returnType = Type.getReturnType(m);
    Type[] argTypes = Type.getArgumentTypes(m);
    Method asmMethod = new Method(methodName, returnType, argTypes);
    GeneratorAdapter mg = new GeneratorAdapter(ACC_PUBLIC, asmMethod, null, getExceptionTypes(m), cv);
    mg.loadThis();
    mg.visitFieldInsn(GETFIELD, subClassName.replace('.', '/'), DELEGATE_FIELD_NAME, Type.getType(delegateClass).getDescriptor());
    mg.loadArgs();
    mg.invokeInterface(Type.getType(delegateClass), asmMethod);
    mg.returnValue();
    mg.endMethod();
}
Also used : GeneratorAdapter(org.objectweb.asm.commons.GeneratorAdapter) Method(org.objectweb.asm.commons.Method)

Example 63 with Method

use of org.objectweb.asm.commons.Method in project Payara by payara.

the class EjbOptionalIntfGenerator method generateSetDelegateMethod.

private static void generateSetDelegateMethod(ClassVisitor cv, Class delegateClass, String subClassName) throws Exception {
    Class optProxyClass = OptionalLocalInterfaceProvider.class;
    java.lang.reflect.Method proxyMethod = optProxyClass.getMethod("setOptionalLocalIntfProxy", java.lang.reflect.Proxy.class);
    String methodName = proxyMethod.getName();
    Type returnType = Type.getReturnType(proxyMethod);
    Type[] argTypes = Type.getArgumentTypes(proxyMethod);
    Type[] eTypes = getExceptionTypes(proxyMethod);
    Method asmMethod = new Method(methodName, returnType, argTypes);
    GeneratorAdapter mg2 = new GeneratorAdapter(ACC_PUBLIC, asmMethod, null, eTypes, cv);
    mg2.visitVarInsn(ALOAD, 0);
    mg2.visitVarInsn(ALOAD, 1);
    mg2.visitTypeInsn(CHECKCAST, delegateClass.getName().replace('.', '/'));
    String delIntClassDesc = Type.getType(delegateClass).getDescriptor();
    mg2.visitFieldInsn(PUTFIELD, subClassName.replace('.', '/'), DELEGATE_FIELD_NAME, delIntClassDesc);
    mg2.returnValue();
    mg2.endMethod();
}
Also used : GeneratorAdapter(org.objectweb.asm.commons.GeneratorAdapter) Method(org.objectweb.asm.commons.Method) OptionalLocalInterfaceProvider(com.sun.ejb.spi.container.OptionalLocalInterfaceProvider)

Example 64 with Method

use of org.objectweb.asm.commons.Method in project Payara by payara.

the class EjbOptionalIntfGenerator method generateInterfaceMethod.

private static void generateInterfaceMethod(ClassVisitor cv, java.lang.reflect.Method m) throws Exception {
    String methodName = m.getName();
    Type returnType = Type.getReturnType(m);
    Type[] argTypes = Type.getArgumentTypes(m);
    Method asmMethod = new Method(methodName, returnType, argTypes);
    GeneratorAdapter cg = new GeneratorAdapter(ACC_PUBLIC + ACC_ABSTRACT, asmMethod, null, getExceptionTypes(m), cv);
    cg.endMethod();
}
Also used : GeneratorAdapter(org.objectweb.asm.commons.GeneratorAdapter) Method(org.objectweb.asm.commons.Method)

Example 65 with Method

use of org.objectweb.asm.commons.Method in project deltaspike by apache.

the class AsmDeltaSpikeProxyClassGenerator method defineDefaultConstructor.

private static void defineDefaultConstructor(ClassWriter cw, Type proxyType, Type superType) {
    GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, new Method("<init>", Type.VOID_TYPE, new Type[] {}), null, null, cw);
    mg.visitCode();
    // invoke super constructor
    mg.loadThis();
    mg.invokeConstructor(superType, Method.getMethod("void <init> ()"));
    mg.returnValue();
    mg.endMethod();
    mg.visitEnd();
}
Also used : Type(org.objectweb.asm.Type) GeneratorAdapter(org.objectweb.asm.commons.GeneratorAdapter) Method(org.objectweb.asm.commons.Method)

Aggregations

Method (org.objectweb.asm.commons.Method)78 GeneratorAdapter (org.objectweb.asm.commons.GeneratorAdapter)58 Type (org.objectweb.asm.Type)38 ClassWriter (org.objectweb.asm.ClassWriter)14 Label (org.objectweb.asm.Label)14 MethodVisitor (org.objectweb.asm.MethodVisitor)9 IOException (java.io.IOException)7 ClassReader (org.objectweb.asm.ClassReader)7 TypeInfo (com.google.template.soy.jbcsrc.restricted.TypeInfo)6 MethodNode (org.objectweb.asm.tree.MethodNode)6 ExprString (lucee.transformer.expression.ExprString)5 LitString (lucee.transformer.expression.literal.LitString)5 ClassVisitor (org.objectweb.asm.ClassVisitor)5 Schema (co.cask.cdap.api.data.schema.Schema)4 ArrayList (java.util.ArrayList)4 File (java.io.File)3 Set (java.util.Set)3 Nullable (javax.annotation.Nullable)3 ExprDouble (lucee.transformer.expression.ExprDouble)3 MetricsContext (co.cask.cdap.api.metrics.MetricsContext)2