54 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 55 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 56 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 57 * THE POSSIBILITY OF SUCH DAMAGE. 58 */ 59 60 package jdk.internal.org.objectweb.asm.commons; 61 62 import jdk.internal.org.objectweb.asm.AnnotationVisitor; 63 import jdk.internal.org.objectweb.asm.Opcodes; 64 65 /** 66 * An {@link AnnotationVisitor} adapter for type remapping. 67 * 68 * @author Eugene Kuleshov 69 */ 70 public class RemappingAnnotationAdapter extends AnnotationVisitor { 71 72 protected final Remapper remapper; 73 74 public RemappingAnnotationAdapter( 75 final AnnotationVisitor av, 76 final Remapper remapper) 77 { 78 this(Opcodes.ASM4, av, remapper); 79 } 80 81 protected RemappingAnnotationAdapter( 82 final int api, 83 final AnnotationVisitor av, 84 final Remapper remapper) 85 { 86 super(api, av); 87 this.remapper = remapper; 88 } 89 90 @Override 91 public void visit(String name, Object value) { 92 av.visit(name, remapper.mapValue(value)); 93 } 94 95 @Override 96 public void visitEnum(String name, String desc, String value) { 97 av.visitEnum(name, remapper.mapDesc(desc), value); 98 } 99 100 @Override 101 public AnnotationVisitor visitAnnotation(String name, String desc) { 102 AnnotationVisitor v = av.visitAnnotation(name, remapper.mapDesc(desc)); 103 return v == null ? null : (v == av 104 ? this 105 : new RemappingAnnotationAdapter(v, remapper)); 106 } 107 108 @Override 109 public AnnotationVisitor visitArray(String name) { 110 AnnotationVisitor v = av.visitArray(name); 111 return v == null ? null : (v == av 112 ? this 113 : new RemappingAnnotationAdapter(v, remapper)); 114 } 115 } | 54 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 55 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 56 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 57 * THE POSSIBILITY OF SUCH DAMAGE. 58 */ 59 60 package jdk.internal.org.objectweb.asm.commons; 61 62 import jdk.internal.org.objectweb.asm.AnnotationVisitor; 63 import jdk.internal.org.objectweb.asm.Opcodes; 64 65 /** 66 * An {@link AnnotationVisitor} adapter for type remapping. 67 * 68 * @author Eugene Kuleshov 69 */ 70 public class RemappingAnnotationAdapter extends AnnotationVisitor { 71 72 protected final Remapper remapper; 73 74 public RemappingAnnotationAdapter(final AnnotationVisitor av, 75 final Remapper remapper) { 76 this(Opcodes.ASM5, av, remapper); 77 } 78 79 protected RemappingAnnotationAdapter(final int api, 80 final AnnotationVisitor av, final Remapper remapper) { 81 super(api, av); 82 this.remapper = remapper; 83 } 84 85 @Override 86 public void visit(String name, Object value) { 87 av.visit(name, remapper.mapValue(value)); 88 } 89 90 @Override 91 public void visitEnum(String name, String desc, String value) { 92 av.visitEnum(name, remapper.mapDesc(desc), value); 93 } 94 95 @Override 96 public AnnotationVisitor visitAnnotation(String name, String desc) { 97 AnnotationVisitor v = av.visitAnnotation(name, remapper.mapDesc(desc)); 98 return v == null ? null : (v == av ? this 99 : new RemappingAnnotationAdapter(v, remapper)); 100 } 101 102 @Override 103 public AnnotationVisitor visitArray(String name) { 104 AnnotationVisitor v = av.visitArray(name); 105 return v == null ? null : (v == av ? this 106 : new RemappingAnnotationAdapter(v, remapper)); 107 } 108 } |