1 4 package com.tc.aspectwerkz.transform.inlining; 5 6 import com.tc.asm.AnnotationVisitor; 7 import com.tc.asm.MethodVisitor; 8 import com.tc.asm.Attribute; 9 10 16 public class AsmCopyAdapter { 17 18 21 public static class CopyAnnotationAdapter implements AnnotationVisitor { 22 23 private final AnnotationVisitor m_from; 24 25 private final AnnotationVisitor m_to; 26 27 public CopyAnnotationAdapter(AnnotationVisitor from, AnnotationVisitor copyTo) { 28 m_from = from; 29 m_to = copyTo; 30 } 31 32 public void visit(String name, Object value) { 33 m_from.visit(name, value); 34 m_to.visit(name, value); 35 } 36 37 public void visitEnum(String name, String desc, String value) { 38 m_from.visitEnum(name, desc, value); 39 m_to.visitEnum(name, desc, value); 40 } 41 42 public AnnotationVisitor visitAnnotation(String name, String desc) { 43 return new CopyAnnotationAdapter( 44 m_from.visitAnnotation(name, desc), 45 m_to.visitAnnotation(name, desc) 46 ); 47 } 48 49 public AnnotationVisitor visitArray(String name) { 50 return new CopyAnnotationAdapter( 51 m_from.visitArray(name), 52 m_to.visitArray(name) 53 ); 54 } 55 56 public void visitEnd() { 57 m_from.visitEnd(); 58 m_to.visitEnd(); 59 } 60 61 } 62 63 67 public static class CopyMethodAnnotationElseNullAdapter extends AsmNullAdapter.NullMethodAdapter { 68 69 private final MethodVisitor m_copyTo; 70 71 public CopyMethodAnnotationElseNullAdapter(MethodVisitor copyTo) { 72 m_copyTo = copyTo; 73 } 74 75 public void visitAttribute(Attribute attr) { 76 m_copyTo.visitAttribute(attr); 77 } 78 79 public AnnotationVisitor visitAnnotation(String desc, boolean visible) { 80 return new CopyAnnotationAdapter( 81 AsmNullAdapter.NullAnnotationVisitor.NULL_ANNOTATION_ADAPTER, 82 m_copyTo.visitAnnotation(desc, visible) 83 ); 84 } 85 86 public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { 87 return new CopyAnnotationAdapter( 88 AsmNullAdapter.NullAnnotationVisitor.NULL_ANNOTATION_ADAPTER, 89 m_copyTo.visitParameterAnnotation(parameter, desc, visible) 90 ); 91 } 92 93 } 94 } 95 | Popular Tags |