Search in sources :

Example 6 with GeneratorAdapter

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();
}
Also used : GeneratorAdapter(org.glassfish.hk2.external.org.objectweb.asm.commons.GeneratorAdapter) Method(org.glassfish.hk2.external.org.objectweb.asm.commons.Method)

Example 7 with GeneratorAdapter

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();
}
Also used : GeneratorAdapter(org.glassfish.hk2.external.org.objectweb.asm.commons.GeneratorAdapter) Method(org.glassfish.hk2.external.org.objectweb.asm.commons.Method)

Example 8 with GeneratorAdapter

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();
}
Also used : Type(org.glassfish.hk2.external.org.objectweb.asm.Type) FlashlightProbe(org.glassfish.flashlight.provider.FlashlightProbe) GeneratorAdapter(org.glassfish.hk2.external.org.objectweb.asm.commons.GeneratorAdapter) Method(org.glassfish.hk2.external.org.objectweb.asm.commons.Method)

Aggregations

GeneratorAdapter (org.glassfish.hk2.external.org.objectweb.asm.commons.GeneratorAdapter)8 Method (org.glassfish.hk2.external.org.objectweb.asm.commons.Method)8 FlashlightProbe (org.glassfish.flashlight.provider.FlashlightProbe)3 ClassWriter (org.glassfish.hk2.external.org.objectweb.asm.ClassWriter)2 Type (org.glassfish.hk2.external.org.objectweb.asm.Type)2 OptionalLocalInterfaceProvider (com.sun.ejb.spi.container.OptionalLocalInterfaceProvider)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 PrivilegedActionException (java.security.PrivilegedActionException)1 ProbeRegistry (org.glassfish.flashlight.provider.ProbeRegistry)1 AnnotationVisitor (org.glassfish.hk2.external.org.objectweb.asm.AnnotationVisitor)1 Label (org.glassfish.hk2.external.org.objectweb.asm.Label)1