1 /*** 2 * ASM: a very small and fast Java bytecode manipulation framework 3 * Copyright (c) 2000-2005 INRIA, France Telecom 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. Neither the name of the copyright holders nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 * THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 package org.objectweb.asm; 31 32 /** 33 * An empty {@link MethodVisitor} that delegates to another 34 * {@link MethodVisitor}. This class can be used as a super class to quickly 35 * implement usefull method adapter classes, just by overriding the necessary 36 * methods. 37 * 38 * @author Eric Bruneton 39 */ 40 public class MethodAdapter implements MethodVisitor { 41 42 /** 43 * The {@link MethodVisitor} to which this adapter delegates calls. 44 */ 45 protected MethodVisitor mv; 46 47 /** 48 * Constructs a new {@link MethodAdapter} object. 49 * 50 * @param mv the code visitor to which this adapter must delegate calls. 51 */ 52 public MethodAdapter(final MethodVisitor mv) { 53 this.mv = mv; 54 } 55 56 public AnnotationVisitor visitAnnotationDefault() { 57 return mv.visitAnnotationDefault(); 58 } 59 60 public AnnotationVisitor visitAnnotation( 61 final String desc, 62 final boolean visible) 63 { 64 return mv.visitAnnotation(desc, visible); 65 } 66 67 // jaime 68 public TypeAnnotationVisitor visitTypeAnnotation(String desc, 69 boolean visible, 70 boolean inCode) 71 { 72 return mv.visitTypeAnnotation(desc, visible, inCode); 73 } 74 //end jaime 75 76 public AnnotationVisitor visitParameterAnnotation( 77 final int parameter, 78 final String desc, 79 final boolean visible) 80 { 81 return mv.visitParameterAnnotation(parameter, desc, visible); 82 } 83 84 public void visitAttribute(final Attribute attr) { 85 mv.visitAttribute(attr); 86 } 87 88 public void visitCode() { 89 mv.visitCode(); 90 } 91 92 public void visitInsn(final int opcode) { 93 mv.visitInsn(opcode); 94 } 95 96 public void visitIntInsn(final int opcode, final int operand) { 97 mv.visitIntInsn(opcode, operand); 98 } 99 100 public void visitVarInsn(final int opcode, final int var) { 101 mv.visitVarInsn(opcode, var); 102 } 103 104 public void visitTypeInsn(final int opcode, final String desc) { 105 mv.visitTypeInsn(opcode, desc); 106 } 107 108 public void visitFieldInsn( 109 final int opcode, 110 final String owner, 111 final String name, 112 final String desc) 113 { 114 mv.visitFieldInsn(opcode, owner, name, desc); 115 } 116 117 public void visitMethodInsn( 118 final int opcode, 119 final String owner, 120 final String name, 121 final String desc) 122 { 123 mv.visitMethodInsn(opcode, owner, name, desc); 124 } 125 126 @Override 127 public void visitInvokeDynamicInsn( 128 final String name, 129 final String desc, 130 final Handle bsm, 131 final Object... bsmArgs) 132 { 133 mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs); 134 } 135 136 public void visitJumpInsn(final int opcode, final Label label) { 137 mv.visitJumpInsn(opcode, label); 138 } 139 140 public void visitLabel(final Label label) { 141 mv.visitLabel(label); 142 } 143 144 public void visitLdcInsn(final Object cst) { 145 mv.visitLdcInsn(cst); 146 } 147 148 public void visitIincInsn(final int var, final int increment) { 149 mv.visitIincInsn(var, increment); 150 } 151 152 public void visitTableSwitchInsn( 153 final int min, 154 final int max, 155 final Label dflt, 156 final Label labels[]) 157 { 158 mv.visitTableSwitchInsn(min, max, dflt, labels); 159 } 160 161 public void visitLookupSwitchInsn( 162 final Label dflt, 163 final int keys[], 164 final Label labels[]) 165 { 166 mv.visitLookupSwitchInsn(dflt, keys, labels); 167 } 168 169 public void visitMultiANewArrayInsn(final String desc, final int dims) { 170 mv.visitMultiANewArrayInsn(desc, dims); 171 } 172 173 @Override 174 public AnnotationVisitor visitInsnAnnotation( 175 int typeRef, 176 TypePath typePath, 177 String desc, 178 boolean visible) 179 { 180 return mv.visitInsnAnnotation(typeRef, typePath, desc, visible); 181 } 182 183 public void visitTryCatchBlock( 184 final Label start, 185 final Label end, 186 final Label handler, 187 final String type) 188 { 189 mv.visitTryCatchBlock(start, end, handler, type); 190 } 191 192 public void visitLocalVariable( 193 final String name, 194 final String desc, 195 final String signature, 196 final Label start, 197 final Label end, 198 final int index) 199 { 200 mv.visitLocalVariable(name, desc, signature, start, end, index); 201 } 202 203 public void visitLineNumber(final int line, final Label start) { 204 mv.visitLineNumber(line, start); 205 } 206 207 public void visitMaxs(final int maxStack, final int maxLocals) { 208 mv.visitMaxs(maxStack, maxLocals); 209 } 210 211 public void visitEnd() { 212 mv.visitEnd(); 213 } 214 } 215