< prev index next >

src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/Remapper.java

Print this page




  66 import jdk.internal.org.objectweb.asm.signature.SignatureVisitor;
  67 import jdk.internal.org.objectweb.asm.signature.SignatureWriter;
  68 
  69 /**
  70  * A class responsible for remapping types and names.
  71  *
  72  * @author Eugene Kuleshov
  73  */
  74 public abstract class Remapper {
  75 
  76     /**
  77       * Returns the given descriptor, remapped with {@link #map(String)}.
  78       *
  79       * @param descriptor a type descriptor.
  80       * @return the given descriptor, with its [array element type] internal name remapped with {@link
  81       *     #map(String)} (if the descriptor corresponds to an array or object type, otherwise the
  82       *     descriptor is returned as is).
  83       */
  84     public String mapDesc(final String descriptor) {
  85         return mapType(Type.getType(descriptor)).getDescriptor();

  86     }
  87 
  88     /**
  89       * Returns the given {@link Type}, remapped with {@link #map(String)} or {@link
  90       * #mapMethodDesc(String)}.
  91       *
  92       * @param type a type, which can be a method type.
  93       * @return the given type, with its [array element type] internal name remapped with {@link
  94       *     #map(String)} (if the type is an array or object type, otherwise the type is returned as
  95       *     is) or, of the type is a method type, with its descriptor remapped with {@link
  96       *     #mapMethodDesc(String)}.
  97       */
  98     private Type mapType(final Type type) {
  99         switch (type.getSort()) {
 100             case Type.ARRAY:
 101                 StringBuilder remappedDescriptor = new StringBuilder();
 102                 for (int i = 0; i < type.getDimensions(); ++i) {
 103                     remappedDescriptor.append('[');
 104                 }
 105                 remappedDescriptor.append(mapType(type.getElementType()).getDescriptor());




  66 import jdk.internal.org.objectweb.asm.signature.SignatureVisitor;
  67 import jdk.internal.org.objectweb.asm.signature.SignatureWriter;
  68 
  69 /**
  70  * A class responsible for remapping types and names.
  71  *
  72  * @author Eugene Kuleshov
  73  */
  74 public abstract class Remapper {
  75 
  76     /**
  77       * Returns the given descriptor, remapped with {@link #map(String)}.
  78       *
  79       * @param descriptor a type descriptor.
  80       * @return the given descriptor, with its [array element type] internal name remapped with {@link
  81       *     #map(String)} (if the descriptor corresponds to an array or object type, otherwise the
  82       *     descriptor is returned as is).
  83       */
  84     public String mapDesc(final String descriptor) {
  85         return mapType(Type.getType(descriptor)).getDescriptor();
  86             // FIXME: support Q-type
  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());


< prev index next >