use of org.glassfish.hk2.external.org.objectweb.asm.commons.GeneratorAdapter 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) throws Exception {
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.glassfish.hk2.external.org.objectweb.asm.commons.GeneratorAdapter in project Payara by payara.
the class BtraceClientGenerator method generateConstructor.
private static void generateConstructor(ClassWriter cw) {
Method m = Method.getMethod("void <init> ()");
GeneratorAdapter gen = new GeneratorAdapter(Opcodes.ACC_PUBLIC, m, null, null, cw);
gen.loadThis();
gen.invokeConstructor(Type.getType(Object.class), m);
// return the value from constructor
gen.returnValue();
gen.endMethod();
}
use of org.glassfish.hk2.external.org.objectweb.asm.commons.GeneratorAdapter in project Payara by payara.
the class ProviderImplGenerator method generateConstructor.
private void generateConstructor(ClassWriter cw, String generatedClassName, FlashlightProbeProvider provider) {
Method m = Method.getMethod("void <init> ()");
GeneratorAdapter gen = new GeneratorAdapter(Opcodes.ACC_PUBLIC, m, null, null, cw);
gen.loadThis();
gen.invokeConstructor(Type.getType(Object.class), m);
Type probeRegType = Type.getType(ProbeRegistry.class);
Type probeType = Type.getType(FlashlightProbe.class);
gen.loadThis();
for (FlashlightProbe probe : provider.getProbes()) {
gen.dup();
String fieldName = "_flashlight_" + probe.getProbeName();
gen.push(probe.getId());
gen.invokeStatic(probeRegType, Method.getMethod("org.glassfish.flashlight.provider.FlashlightProbe getProbeById(int)"));
gen.visitFieldInsn(Opcodes.PUTFIELD, generatedClassName, fieldName, probeType.getDescriptor());
}
gen.pop();
// return the value from constructor
gen.returnValue();
gen.endMethod();
}
Aggregations