Home | History | Annotate | Download | only in stubber
      1 /*
      2  * Copyright (C) 2009 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.mkstubs.stubber;
     18 
     19 import org.objectweb.asm.AnnotationVisitor;
     20 import org.objectweb.asm.Attribute;
     21 import org.objectweb.asm.ClassVisitor;
     22 import org.objectweb.asm.FieldVisitor;
     23 import org.objectweb.asm.MethodVisitor;
     24 import org.objectweb.asm.Opcodes;
     25 
     26 /**
     27  * A class visitor that generates stubs for all methods of the visited class.
     28  * Everything else is passed as-is.
     29  */
     30 public class ClassStubber extends ClassVisitor {
     31 
     32     public ClassStubber(ClassVisitor cv) {
     33         super(Opcodes.ASM4, cv);
     34     }
     35 
     36     @Override
     37     public void visit(int version, int access,
     38             String name,
     39             String signature,
     40             String superName,
     41             String[] interfaces) {
     42         super.visit(version, access, name, signature, superName, interfaces);
     43     }
     44 
     45     @Override
     46     public void visitEnd() {
     47         super.visitEnd();
     48     }
     49 
     50     @Override
     51     public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
     52         return super.visitAnnotation(desc, visible);
     53     }
     54 
     55     @Override
     56     public void visitAttribute(Attribute attr) {
     57         super.visitAttribute(attr);
     58     }
     59 
     60     @Override
     61     public MethodVisitor visitMethod(int access, String name, String desc, String signature,
     62             String[] exceptions) {
     63         MethodVisitor mw = super.visitMethod(access, name, desc, signature, exceptions);
     64         return new MethodStubber(mw, access, name, desc, signature, exceptions);
     65     }
     66 
     67     @Override
     68     public FieldVisitor visitField(int access, String name, String desc, String signature,
     69             Object value) {
     70         return super.visitField(access, name, desc, signature, value);
     71     }
     72 
     73     @Override
     74     public void visitInnerClass(String name, String outerName, String innerName, int access) {
     75         super.visitInnerClass(name, outerName, innerName, access);
     76     }
     77 
     78     @Override
     79     public void visitOuterClass(String owner, String name, String desc) {
     80         super.visitOuterClass(owner, name, desc);
     81     }
     82 
     83     @Override
     84     public void visitSource(String source, String debug) {
     85         super.visitSource(source, debug);
     86     }
     87 }
     88