FileDocCategorySizeDatePackage
MethodStubber.javaAPI DocAndroid 1.5 API5323Wed May 06 22:41:10 BST 2009com.android.mkstubs.stubber

MethodStubber

public class MethodStubber extends org.objectweb.asm.MethodAdapter
A method visitor that generates a code stub for the visited method.

Annotations and parameters are passed as-is. All other code is replaced by the following:

throw new RuntimeException("stub");
Note that constructors rewritten this way will probably fail with the runtime bytecode verifier since no call to super is generated.

Fields Summary
Constructors Summary
public MethodStubber(org.objectweb.asm.MethodVisitor mw, int access, String name, String desc, String signature, String[] exceptions)

        super(mw);
    
Methods Summary
public org.objectweb.asm.AnnotationVisitorvisitAnnotation(java.lang.String desc, boolean visible)

        return super.visitAnnotation(desc, visible);
    
public org.objectweb.asm.AnnotationVisitorvisitAnnotationDefault()

        return super.visitAnnotationDefault();
    
public voidvisitAttribute(org.objectweb.asm.Attribute attr)

        super.visitAttribute(attr);
    
public voidvisitCode()

        Label l0 = new Label();
        mv.visitLabel(l0);
        mv.visitLineNumber(36, l0);
        mv.visitTypeInsn(Opcodes.NEW, "java/lang/RuntimeException");
        mv.visitInsn(Opcodes.DUP);
        mv.visitLdcInsn("stub");
        mv.visitMethodInsn(
                Opcodes.INVOKESPECIAL,          // opcode
                "java/lang/RuntimeException",   // owner
                "<init>",                       // name
                "(Ljava/lang/String;)V");       // desc
        mv.visitInsn(Opcodes.ATHROW);
        Label l1 = new Label();
        mv.visitLabel(l1);
        mv.visitLocalVariable(
                "this",                                         // name
                "Lcom/android/mkstubs/stubber/MethodStubber;",  // desc
                null,                                           // signature
                l0,                                             // label start
                l1,                                             // label end
                0);                                             // index
        mv.visitMaxs(3, 1); // maxStack, maxLocals
    
public voidvisitEnd()

        super.visitEnd();
    
public voidvisitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)

        // skip
    
public voidvisitFrame(int type, int local, java.lang.Object[] local2, int stack, java.lang.Object[] stack2)

        // skip
    
public voidvisitIincInsn(int var, int increment)

        // skip
    
public voidvisitInsn(int opcode)

        // skip
    
public voidvisitIntInsn(int opcode, int operand)

        // skip
    
public voidvisitJumpInsn(int opcode, org.objectweb.asm.Label label)

        // skip
    
public voidvisitLabel(org.objectweb.asm.Label label)

        // skip
    
public voidvisitLdcInsn(java.lang.Object cst)

        // skip
    
public voidvisitLineNumber(int line, org.objectweb.asm.Label start)

        // skip
    
public voidvisitLocalVariable(java.lang.String name, java.lang.String desc, java.lang.String signature, org.objectweb.asm.Label start, org.objectweb.asm.Label end, int index)

        // skip
    
public voidvisitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)

        // skip
    
public voidvisitMaxs(int maxStack, int maxLocals)

        // skip
    
public voidvisitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)

        // skip
    
public voidvisitMultiANewArrayInsn(java.lang.String desc, int dims)

        // skip
    
public org.objectweb.asm.AnnotationVisitorvisitParameterAnnotation(int parameter, java.lang.String desc, boolean visible)

        return super.visitParameterAnnotation(parameter, desc, visible);
    
public voidvisitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels)

        // skip
    
public voidvisitTryCatchBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label handler, java.lang.String type)

        // skip
    
public voidvisitTypeInsn(int opcode, java.lang.String type)

        // skip
    
public voidvisitVarInsn(int opcode, int var)

        // skip