67 import jdk.internal.org.objectweb.asm.signature.SignatureVisitor;
68 import jdk.internal.org.objectweb.asm.signature.SignatureWriter;
69
70 /**
71 * A class responsible for remapping types and names.
72 *
73 * @author Eugene Kuleshov
74 */
75 public abstract class Remapper {
76
77 /**
78 * Returns the given descriptor, remapped with {@link #map(String)}.
79 *
80 * @param descriptor a type descriptor.
81 * @return the given descriptor, with its [array element type] internal name remapped with {@link
82 * #map(String)} (if the descriptor corresponds to an array or object type, otherwise the
83 * descriptor is returned as is).
84 */
85 public String mapDesc(final String descriptor) {
86 return mapType(Type.getType(descriptor)).getDescriptor();
87 }
88
89 /**
90 * Returns the given {@link Type}, remapped with {@link #map(String)} or {@link
91 * #mapMethodDesc(String)}.
92 *
93 * @param type a type, which can be a method type.
94 * @return the given type, with its [array element type] internal name remapped with {@link
95 * #map(String)} (if the type is an array or object type, otherwise the type is returned as
96 * is) or, of the type is a method type, with its descriptor remapped with {@link
97 * #mapMethodDesc(String)}.
98 */
99 private Type mapType(final Type type) {
100 switch (type.getSort()) {
101 case Type.ARRAY:
102 StringBuilder remappedDescriptor = new StringBuilder();
103 for (int i = 0; i < type.getDimensions(); ++i) {
104 remappedDescriptor.append('[');
105 }
106 remappedDescriptor.append(mapType(type.getElementType()).getDescriptor());
|
67 import jdk.internal.org.objectweb.asm.signature.SignatureVisitor;
68 import jdk.internal.org.objectweb.asm.signature.SignatureWriter;
69
70 /**
71 * A class responsible for remapping types and names.
72 *
73 * @author Eugene Kuleshov
74 */
75 public abstract class Remapper {
76
77 /**
78 * Returns the given descriptor, remapped with {@link #map(String)}.
79 *
80 * @param descriptor a type descriptor.
81 * @return the given descriptor, with its [array element type] internal name remapped with {@link
82 * #map(String)} (if the descriptor corresponds to an array or object type, otherwise the
83 * descriptor is returned as is).
84 */
85 public String mapDesc(final String descriptor) {
86 return mapType(Type.getType(descriptor)).getDescriptor();
87 // FIXME: support Q-type
88 }
89
90 /**
91 * Returns the given {@link Type}, remapped with {@link #map(String)} or {@link
92 * #mapMethodDesc(String)}.
93 *
94 * @param type a type, which can be a method type.
95 * @return the given type, with its [array element type] internal name remapped with {@link
96 * #map(String)} (if the type is an array or object type, otherwise the type is returned as
97 * is) or, of the type is a method type, with its descriptor remapped with {@link
98 * #mapMethodDesc(String)}.
99 */
100 private Type mapType(final Type type) {
101 switch (type.getSort()) {
102 case Type.ARRAY:
103 StringBuilder remappedDescriptor = new StringBuilder();
104 for (int i = 0; i < type.getDimensions(); ++i) {
105 remappedDescriptor.append('[');
106 }
107 remappedDescriptor.append(mapType(type.getElementType()).getDescriptor());
|