Example usage for org.objectweb.asm.commons GeneratorAdapter getArgumentTypes

List of usage examples for org.objectweb.asm.commons GeneratorAdapter getArgumentTypes

Introduction

In this page you can find the example usage for org.objectweb.asm.commons GeneratorAdapter getArgumentTypes.

Prototype

public Type[] getArgumentTypes() 

Source Link

Usage

From source file:org.glowroot.agent.weaving.PointcutClassVisitor.java

License:Apache License

@Override
public void visitEnd() {
    if (onBeforeMethodVisitor != null) {
        int access = onBeforeMethodVisitor.access;
        String name = onBeforeMethodVisitor.name;
        String descriptor = "(Z" + onBeforeMethodVisitor.descriptor.substring(1);
        String signature = onBeforeMethodVisitor.signature;
        String[] exceptions = onBeforeMethodVisitor.exceptions;
        GeneratorAdapter mv = new GeneratorAdapter(
                cw.visitMethod(access, name, descriptor, signature, exceptions), access, name, descriptor);
        mv.visitCode();//  www  .ja  v  a  2  s .co  m
        mv.visitVarInsn(ILOAD, 0);
        Label endWithDefaultLabel = new Label();
        mv.visitJumpInsn(IFEQ, endWithDefaultLabel);
        mv.loadArgs(1, mv.getArgumentTypes().length - 1);
        mv.visitMethodInsn(INVOKESTATIC, checkNotNull(className), name, onBeforeMethodVisitor.descriptor,
                false);
        mv.returnValue();

        mv.visitLabel(endWithDefaultLabel);
        mv.visitFrame(F_NEW, 0, new Object[0], 0, new Object[0]);
        if (mv.getReturnType().getSort() != Type.VOID) {
            // return value will be ignored when !enabled, but need to return something
            WeavingMethodVisitor.pushDefault(mv, mv.getReturnType());
        }
        mv.returnValue();
        mv.endMethod();
    }
    super.visitEnd();
}