3030
3131import java .util .Collections ;
3232import java .util .Map ;
33+ import org .objectweb .asm .Handle ;
34+ import org .objectweb .asm .Opcodes ;
3335
3436/**
3537 * A {@link Remapper} using a {@link Map} to define its mapping.
@@ -58,23 +60,69 @@ public class SimpleRemapper extends Remapper {
5860 * <li>for internal names, the key is the old internal name, and the value is the new
5961 * internal name (see {@link org.objectweb.asm.Type#getInternalName()}).
6062 * </ul>
63+ *
64+ * @deprecated use {@link #SimpleRemapper(int, Map)} instead.
6165 */
66+ @ Deprecated
6267 public SimpleRemapper (final Map <String , String > mapping ) {
6368 this .mapping = mapping ;
6469 }
6570
71+ /**
72+ * Constructs a new {@link SimpleRemapper} with the given mapping.
73+ *
74+ * @param api the ASM API version supported by this remapper. Must be one of the {@code
75+ * ASM}<i>x</i> values in {@link Opcodes}.
76+ * @param mapping a map specifying a remapping as follows:
77+ * <ul>
78+ * <li>for method names, the key is the owner, name and descriptor of the method (in the
79+ * form <owner>.<name><descriptor>), and the value is the new method
80+ * name.
81+ * <li>for invokedynamic method names, the key is the name and descriptor of the method (in
82+ * the form .<name><descriptor>), and the value is the new method name.
83+ * <li>for field names, the key is the owner and name of the field or attribute (in the form
84+ * <owner>.<name>), and the value is the new field name.
85+ * <li>for attribute names, the key is the annotation descriptor and the name of the
86+ * attribute (in the form <descriptor>.<name>), and the value is the new
87+ * attribute name.
88+ * <li>for internal names, the key is the old internal name, and the value is the new
89+ * internal name (see {@link org.objectweb.asm.Type#getInternalName()}).
90+ * </ul>
91+ */
92+ public SimpleRemapper (final int api , final Map <String , String > mapping ) {
93+ super (api );
94+ this .mapping = mapping ;
95+ }
96+
6697 /**
6798 * Constructs a new {@link SimpleRemapper} with the given mapping.
6899 *
69100 * @param oldName the key corresponding to a method, field or internal name (see {@link
70101 * #SimpleRemapper(Map)} for the format of these keys).
71102 * @param newName the new method, field or internal name (see {@link
72103 * org.objectweb.asm.Type#getInternalName()}).
104+ * @deprecated use {@link #SimpleRemapper(int, String, String)} instead.
73105 */
106+ @ Deprecated
74107 public SimpleRemapper (final String oldName , final String newName ) {
75108 this .mapping = Collections .singletonMap (oldName , newName );
76109 }
77110
111+ /**
112+ * Constructs a new {@link SimpleRemapper} with the given mapping.
113+ *
114+ * @param api the ASM API version supported by this remapper. Must be one of the {@code
115+ * ASM}<i>x</i> values in {@link Opcodes}.
116+ * @param oldName the key corresponding to a method, field or internal name (see {@link
117+ * #SimpleRemapper(Map)} for the format of these keys).
118+ * @param newName the new method, field or internal name (see {@link
119+ * org.objectweb.asm.Type#getInternalName()}).
120+ */
121+ public SimpleRemapper (final int api , final String oldName , final String newName ) {
122+ super (api );
123+ this .mapping = Collections .singletonMap (oldName , newName );
124+ }
125+
78126 @ Override
79127 public String mapMethodName (final String owner , final String name , final String descriptor ) {
80128 String remappedName = map (owner + '.' + name + descriptor );
@@ -87,6 +135,16 @@ public String mapInvokeDynamicMethodName(final String name, final String descrip
87135 return remappedName == null ? name : remappedName ;
88136 }
89137
138+ @ Override
139+ public String mapInvokeDynamicMethodName (
140+ final String name ,
141+ final String descriptor ,
142+ final Handle bootstrapMethodHandle ,
143+ final Object ... bootstrapMethodArguments ) {
144+ String remappedName = map ('.' + name + descriptor );
145+ return remappedName == null ? name : remappedName ;
146+ }
147+
90148 @ Override
91149 public String mapAnnotationAttributeName (final String descriptor , final String name ) {
92150 String remappedName = map (descriptor + '.' + name );
0 commit comments