001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.xbean.asm5.original.commons; 018 019import org.objectweb.asm.AnnotationVisitor; 020import org.objectweb.asm.Attribute; 021import org.objectweb.asm.ClassVisitor; 022import org.objectweb.asm.FieldVisitor; 023import org.objectweb.asm.Handle; 024import org.objectweb.asm.Label; 025import org.objectweb.asm.MethodVisitor; 026import org.objectweb.asm.Opcodes; 027import org.objectweb.asm.TypePath; 028 029public class EmptyVisitor extends ClassVisitor { 030 protected final AnnotationVisitor av = new AnnotationVisitor(Opcodes.ASM5) { 031 @Override 032 public void visit(String name, Object value) { 033 EmptyVisitor.this.visit(name, value); 034 } 035 036 @Override 037 public void visitEnum(String name, String desc, String value) { 038 EmptyVisitor.this.visitEnum(name, desc, value); 039 } 040 041 @Override 042 public AnnotationVisitor visitAnnotation(String name, String desc) { 043 return EmptyVisitor.this.visitAnnotation(name, desc); 044 } 045 046 @Override 047 public AnnotationVisitor visitArray(String name) { 048 return EmptyVisitor.this.visitArray(name); 049 } 050 051 @Override 052 public void visitEnd() { 053 EmptyVisitor.this.visitEnd(); 054 } 055 }; 056 057 protected final FieldVisitor fv = new FieldVisitor(Opcodes.ASM5) { 058 @Override 059 public AnnotationVisitor visitAnnotation(String desc, boolean visible) { 060 return EmptyVisitor.this.visitAnnotation(desc, visible); 061 } 062 063 @Override 064 public void visitAttribute(Attribute attribute) { 065 EmptyVisitor.this.visitAttribute(attribute); 066 } 067 068 @Override 069 public void visitEnd() { 070 EmptyVisitor.this.visitEnd(); 071 } 072 }; 073 protected final MethodVisitor mv = new MethodVisitor(Opcodes.ASM4) { 074 @Override 075 public AnnotationVisitor visitAnnotationDefault() { 076 return EmptyVisitor.this.visitAnnotationDefault(); 077 } 078 079 @Override 080 public AnnotationVisitor visitAnnotation(String desc, boolean visible) { 081 return EmptyVisitor.this.visitAnnotation(desc, visible); 082 } 083 084 @Override 085 public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { 086 return EmptyVisitor.this.visitMethodParameterAnnotation(parameter, desc, visible); 087 } 088 089 @Override 090 public void visitAttribute(Attribute attribute) { 091 EmptyVisitor.this.visitAttribute(attribute); 092 } 093 094 @Override 095 public void visitCode() { 096 EmptyVisitor.this.visitCode(); 097 } 098 099 @Override 100 public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) { 101 EmptyVisitor.this.visitFrame(type, nLocal, local, nStack, stack); 102 } 103 104 @Override 105 public void visitInsn(int opcode) { 106 EmptyVisitor.this.visitInsn(opcode); 107 } 108 109 @Override 110 public void visitJumpInsn(int i, Label label) { 111 EmptyVisitor.this.visitJumpInsn(i, label); 112 } 113 114 @Override 115 public void visitLabel(Label label) { 116 EmptyVisitor.this.visitLabel(label); 117 } 118 119 @Override 120 public void visitLdcInsn(Object cst) { 121 EmptyVisitor.this.visitLdcInsn(cst); 122 } 123 124 @Override 125 public void visitIincInsn(int var, int increment) { 126 EmptyVisitor.this.visitIincInsn(var, increment); 127 } 128 129 @Override 130 public void visitTableSwitchInsn(int i, int i2, Label label, Label... labels) { 131 EmptyVisitor.this.visitTableSwitchInsn(i, i2, label, labels); 132 } 133 134 @Override 135 public void visitLookupSwitchInsn(Label label, int[] ints, Label[] labels) { 136 EmptyVisitor.this.visitLookupSwitchInsn(label, ints, labels); 137 } 138 139 @Override 140 public void visitMultiANewArrayInsn(String desc, int dims) { 141 EmptyVisitor.this.visitMultiANewArrayInsn(desc, dims); 142 } 143 144 @Override 145 public void visitTryCatchBlock(Label label, Label label2, Label label3, String s) { 146 EmptyVisitor.this.visitTryCatchBlock(label, label2, label3, s); 147 } 148 149 @Override 150 public void visitLocalVariable(String s, String s2, String s3, Label label, Label label2, int i) { 151 EmptyVisitor.this.visitLocalVariable(s, s2, s3, label, label2, i); 152 } 153 154 @Override 155 public void visitLineNumber(int i, Label label) { 156 EmptyVisitor.this.visitLineNumber(i, label); 157 } 158 159 @Override 160 public void visitMaxs(int maxStack, int maxLocals) { 161 EmptyVisitor.this.visitMaxs(maxStack, maxLocals); 162 } 163 164 @Override 165 public void visitEnd() { 166 EmptyVisitor.this.visitEnd(); 167 } 168 169 @Override 170 public void visitIntInsn(int opcode, int operand) { 171 EmptyVisitor.this.visitIntInsn(opcode, operand); 172 } 173 174 @Override 175 public void visitVarInsn(int opcode, int var) { 176 EmptyVisitor.this.visitVarInsn(opcode, var); 177 } 178 179 @Override 180 public void visitTypeInsn(int opcode, String type) { 181 EmptyVisitor.this.visitTypeInsn(opcode, type); 182 } 183 184 @Override 185 public void visitFieldInsn(int opcode, String owner, String name, String desc) { 186 EmptyVisitor.this.visitFieldInsn(opcode, owner, name, desc); 187 } 188 189 @Override 190 public void visitMethodInsn(int opcode, String owner, String name, String desc) { 191 EmptyVisitor.this.visitMethodInsn(opcode, owner, name, desc); 192 } 193 194 @Override 195 public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { 196 EmptyVisitor.this.visitMethodInsn(opcode, owner, name, desc); 197 } 198 199 @Override 200 public void visitInvokeDynamicInsn(String s, String s2, Handle handle, Object... objects) { 201 EmptyVisitor.this.visitInvokeDynamicInsn(s, s2, handle, objects); 202 } 203 }; 204 205 public EmptyVisitor() { 206 super(Opcodes.ASM5); 207 } 208 209 protected AnnotationVisitor visitAnnotationDefault() { 210 return av; 211 } 212 213 protected AnnotationVisitor visitArray(String name) { 214 return av; 215 } 216 217 protected AnnotationVisitor visitAnnotation(String name, String desc) { 218 return av; 219 } 220 221 protected void visitEnum(String name, String desc, String value) { 222 // no-op 223 } 224 225 protected void visit(String name, Object value) { 226 // no-op 227 } 228 229 protected void visitVarInsn(int opcode, int var) { 230 // no-op 231 } 232 233 protected void visitTypeInsn(int opcode, String type) { 234 // no-op 235 } 236 237 protected void visitFieldInsn(int opcode, String owner, String name, String desc) { 238 // no-op 239 } 240 241 protected void visitMethodInsn(int opcode, String owner, String name, String desc) { 242 // no-op 243 } 244 245 protected void visitInvokeDynamicInsn(String s, String s2, Handle handle, Object[] objects) { 246 // no-op 247 } 248 249 protected void visitIntInsn(int opcode, int operand) { 250 // no-op 251 } 252 253 protected void visitJumpInsn(int i, Label label) { 254 // no-op 255 } 256 257 protected void visitLabel(Label label) { 258 // no-op 259 } 260 261 protected void visitLdcInsn(Object cst) { 262 // no-op 263 } 264 265 protected void visitIincInsn(int var, int increment) { 266 // no-op 267 } 268 269 protected void visitTableSwitchInsn(int i, int i2, Label label, Label[] labels) { 270 // no-op 271 } 272 273 protected void visitLookupSwitchInsn(Label label, int[] ints, Label[] labels) { 274 // no-op 275 } 276 277 protected void visitMultiANewArrayInsn(String desc, int dims) { 278 // no-op 279 } 280 281 protected void visitTryCatchBlock(Label label, Label label2, Label label3, String s) { 282 // no-op 283 } 284 285 protected void visitLocalVariable(String s, String s2, String s3, Label label, Label label2, int i) { 286 // no-op 287 } 288 289 protected void visitLineNumber(int i, Label label) { 290 // no-op 291 } 292 293 protected void visitMaxs(int maxStack, int maxLocals) { 294 // no-op 295 } 296 297 protected void visitInsn(int opcode) { 298 // no-op 299 } 300 301 protected void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) { 302 // no-op 303 } 304 305 protected void visitCode() { 306 // no-op 307 } 308 309 protected AnnotationVisitor visitMethodParameterAnnotation(int parameter, String desc, boolean visible) { 310 return av; 311 } 312 313 protected AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { 314 return av; 315 } 316 317 @Override 318 public void visit(int version, int access, String name, String signature, 319 String superName, String[] interfaces) { 320 if (cv != null) { 321 cv.visit(version, access, name, signature, superName, interfaces); 322 } 323 } 324 325 @Override 326 public void visitSource(String source, String debug) { 327 if (cv != null) { 328 cv.visitSource(source, debug); 329 } 330 } 331 332 @Override 333 public void visitOuterClass(String owner, String name, String desc) { 334 if (cv != null) { 335 cv.visitOuterClass(owner, name, desc); 336 } 337 } 338 339 @Override 340 public AnnotationVisitor visitAnnotation(String desc, boolean visible) { 341 return av; 342 } 343 344 @Override 345 public void visitAttribute(Attribute attr) { 346 if (cv != null) { 347 cv.visitAttribute(attr); 348 } 349 } 350 351 @Override 352 public void visitInnerClass(String name, String outerName, 353 String innerName, int access) { 354 if (cv != null) { 355 cv.visitInnerClass(name, outerName, innerName, access); 356 } 357 } 358 359 @Override 360 public FieldVisitor visitField(int access, String name, String desc, 361 String signature, Object value) { 362 return fv; 363 } 364 365 @Override 366 public MethodVisitor visitMethod(int access, String name, String desc, 367 String signature, String[] exceptions) { 368 return mv; 369 } 370 371 @Override 372 public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { 373 return av; 374 } 375 376 @Override 377 public void visitEnd() { 378 if (cv != null) { 379 cv.visitEnd(); 380 } 381 } 382 383 public AnnotationVisitor annotationVisitor() { 384 return av; 385 } 386 387 public FieldVisitor fieldVisitor() { 388 return fv; 389 } 390 391 public MethodVisitor methodVisitor() { 392 return mv; 393 } 394}