45 * this software without specific prior written permission. 46 * 47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 48 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 50 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 51 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 53 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 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.FieldVisitor; 64 import jdk.internal.org.objectweb.asm.Opcodes; 65 66 /** 67 * A {@link FieldVisitor} adapter for type remapping. 68 * 69 * @author Eugene Kuleshov 70 */ 71 public class RemappingFieldAdapter extends FieldVisitor { 72 73 private final Remapper remapper; 74 75 public RemappingFieldAdapter(final FieldVisitor fv, final Remapper remapper) 76 { 77 this(Opcodes.ASM4, fv, remapper); 78 } 79 80 protected RemappingFieldAdapter( 81 final int api, 82 final FieldVisitor fv, 83 final Remapper remapper) 84 { 85 super(api, fv); 86 this.remapper = remapper; 87 } 88 89 @Override 90 public AnnotationVisitor visitAnnotation(String desc, boolean visible) { 91 AnnotationVisitor av = fv.visitAnnotation(remapper.mapDesc(desc), visible); 92 return av == null ? null : new RemappingAnnotationAdapter(av, remapper); 93 } 94 } | 45 * this software without specific prior written permission. 46 * 47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 48 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 50 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 51 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 53 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 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.FieldVisitor; 64 import jdk.internal.org.objectweb.asm.Opcodes; 65 import jdk.internal.org.objectweb.asm.TypePath; 66 67 /** 68 * A {@link FieldVisitor} adapter for type remapping. 69 * 70 * @author Eugene Kuleshov 71 */ 72 public class RemappingFieldAdapter extends FieldVisitor { 73 74 private final Remapper remapper; 75 76 public RemappingFieldAdapter(final FieldVisitor fv, final Remapper remapper) { 77 this(Opcodes.ASM5, fv, remapper); 78 } 79 80 protected RemappingFieldAdapter(final int api, final FieldVisitor fv, 81 final Remapper remapper) { 82 super(api, fv); 83 this.remapper = remapper; 84 } 85 86 @Override 87 public AnnotationVisitor visitAnnotation(String desc, boolean visible) { 88 AnnotationVisitor av = fv.visitAnnotation(remapper.mapDesc(desc), 89 visible); 90 return av == null ? null : new RemappingAnnotationAdapter(av, remapper); 91 } 92 93 @Override 94 public AnnotationVisitor visitTypeAnnotation(int typeRef, 95 TypePath typePath, String desc, boolean visible) { 96 AnnotationVisitor av = super.visitTypeAnnotation(typeRef, typePath, 97 remapper.mapDesc(desc), visible); 98 return av == null ? null : new RemappingAnnotationAdapter(av, remapper); 99 } 100 } |