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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations