Class Remapper

java.lang.Object
org.objectweb.asm.commons.Remapper
Direct Known Subclasses:
SimpleRemapper

public abstract class Remapper extends Object
A class responsible for remapping types and names.
  • Constructor Details

    • Remapper

      @Deprecated(forRemoval=false) protected Remapper()
      Deprecated.
      use Remapper(int) instead.
      Creates a new Remapper.
    • Remapper

      protected Remapper(int api)
      Creates a new Remapper.
      Parameters:
      api - the ASM API version supported by this remapper. Must be one of the ASMx values in Opcodes.
  • Method Details

    • mapDesc

      public String mapDesc(String descriptor)
      Returns the given descriptor, remapped with map(String).
      Parameters:
      descriptor - a type descriptor.
      Returns:
      the given descriptor, with its [array element type] internal name remapped with map(String) (if the descriptor corresponds to an array or object type, otherwise the descriptor is returned as is). See Type.getInternalName().
    • mapType

      public String mapType(String internalName)
      Returns the given internal name, remapped with map(String).
      Parameters:
      internalName - the internal name (or array type descriptor) of some (array) class (see Type.getInternalName()).
      Returns:
      the given internal name, remapped with map(String) (see Type.getInternalName()).
    • mapTypes

      public String[] mapTypes(String[] internalNames)
      Returns the given internal names, remapped with map(String).
      Parameters:
      internalNames - the internal names (or array type descriptors) of some (array) classes (see Type.getInternalName()).
      Returns:
      the given internal name, remapped with map(String) (see Type.getInternalName()).
    • mapMethodDesc

      public String mapMethodDesc(String methodDescriptor)
      Returns the given method descriptor, with its argument and return type descriptors remapped with mapDesc(String).
      Parameters:
      methodDescriptor - a method descriptor.
      Returns:
      the given method descriptor, with its argument and return type descriptors remapped with mapDesc(String).
    • mapValue

      public Object mapValue(Object value)
      Returns the given value, remapped with this remapper. Possible values are Boolean, Byte, Short, Character, Integer, Long, Double, Float, String, Type, Handle, ConstantDynamic or arrays of primitive types .
      Parameters:
      value - an object. Only Type, Handle and ConstantDynamic values are remapped.
      Returns:
      the given value, remapped with this remapper.
    • mapSignature

      public String mapSignature(String signature, boolean typeSignature)
      Returns the given signature, remapped with the SignatureVisitor returned by createSignatureRemapper(SignatureVisitor).
      Parameters:
      signature - a JavaTypeSignature, ClassSignature or MethodSignature.
      typeSignature - whether the given signature is a JavaTypeSignature.
      Returns:
      signature the given signature, remapped with the SignatureVisitor returned by createSignatureRemapper(SignatureVisitor).
    • createRemappingSignatureAdapter

      @Deprecated(forRemoval=false) protected org.objectweb.asm.signature.SignatureVisitor createRemappingSignatureAdapter(org.objectweb.asm.signature.SignatureVisitor signatureVisitor)
      Constructs a new remapper for signatures. The default implementation of this method returns a new SignatureRemapper.
      Parameters:
      signatureVisitor - the SignatureVisitor the remapper must delegate to.
      Returns:
      the newly created remapper.
    • createSignatureRemapper

      protected org.objectweb.asm.signature.SignatureVisitor createSignatureRemapper(org.objectweb.asm.signature.SignatureVisitor signatureVisitor)
      Constructs a new remapper for signatures. The default implementation of this method returns a new SignatureRemapper.
      Parameters:
      signatureVisitor - the SignatureVisitor the remapper must delegate to.
      Returns:
      the newly created remapper.
    • mapAnnotationAttributeName

      public String mapAnnotationAttributeName(String descriptor, String name)
      Maps an annotation attribute name. The default implementation of this method returns the given name, unchanged. Subclasses can override.
      Parameters:
      descriptor - the descriptor of the annotation class.
      name - the name of the annotation attribute.
      Returns:
      the new name of the annotation attribute.
    • mapInnerClassName

      public String mapInnerClassName(String name, String ownerName, String innerName)
      Maps an inner class name to its new name. The default implementation of this method provides a strategy that will work for inner classes produced by Java, but not necessarily other languages. Subclasses can override.
      Parameters:
      name - the fully-qualified internal name of the inner class (see Type.getInternalName()).
      ownerName - the internal name of the owner class of the inner class (see Type.getInternalName()).
      innerName - the internal name of the inner class (see Type.getInternalName()).
      Returns:
      the new inner name of the inner class.
    • mapMethodName

      public String mapMethodName(String owner, String name, String descriptor)
      Maps a method name to its new name. The default implementation of this method returns the given name, unchanged. Subclasses can override.
      Parameters:
      owner - the internal name of the owner class of the method (see Type.getInternalName()).
      name - the name of the method.
      descriptor - the descriptor of the method.
      Returns:
      the new name of the method.
    • mapInvokeDynamicMethodName

      @Deprecated(forRemoval=false) public String mapInvokeDynamicMethodName(String name, String descriptor)
      Maps an invokedynamic or a constant dynamic method name to its new name. The default implementation of this method returns the given name, unchanged. Subclasses can override.
      Parameters:
      name - the name of the method.
      descriptor - the descriptor of the method.
      Returns:
      the new name of the method.
    • mapInvokeDynamicMethodName

      public String mapInvokeDynamicMethodName(String name, String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, Object... bootstrapMethodArguments)
      Maps an invokedynamic or a constant dynamic method name to its new name. Subclasses can override.

      The default implementation of this method first performs well-known rule checks (calling mapWellKnownInvokeDynamicMethodName(String, String, Handle, Object...)) and then performs basic remapping (calling mapBasicInvokeDynamicMethodName(String, String, Handle, Object...)).

      For most users, only mapBasicInvokeDynamicMethodName(String, String, Handle, Object...) needs to be overridden.

      Parameters:
      name - the name of the method.
      descriptor - the descriptor of the method.
      bootstrapMethodHandle - the bootstrap method.
      bootstrapMethodArguments - the bootstrap method constant arguments. Each argument must be an Integer, Float, Long, Double, String, Type, Handle or ConstantDynamic value. This method is allowed to modify the content of the array so a caller should expect that this array may change.
      Returns:
      the new name of the method.
    • mapWellKnownInvokeDynamicMethodName

      public String mapWellKnownInvokeDynamicMethodName(String name, String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, Object... bootstrapMethodArguments)
      Maps well-known invokedynamic (e.g. lambda creation) or const dynamic method names to their new names. This method detects specific invokedynamic method rules and remaps using the corresponding rules. When no rule is matched, returns null. When non-null is returned, it means that this invokedynamic method name matches a rule and has been remapped with the relevant rule. Subclasses can override.
      Parameters:
      name - the name of the method.
      descriptor - the descriptor of the method.
      bootstrapMethodHandle - the bootstrap method.
      bootstrapMethodArguments - the bootstrap method constant arguments. Each argument must be an Integer, Float, Long, Double, String, Type, Handle or ConstantDynamic value. This method is allowed to modify the content of the array so a caller should expect that this array may change.
      Returns:
      the new name of the method, or null if no special rule is matched.
    • mapBasicInvokeDynamicMethodName

      public String mapBasicInvokeDynamicMethodName(String name, String descriptor, org.objectweb.asm.Handle bootstrapMethodHandle, Object... bootstrapMethodArguments)
      Maps an invokedynamic or a constant dynamic method name to its new name. The default implementation of this method returns the given name, unchanged. Subclasses can override.
      Parameters:
      name - the name of the method.
      descriptor - the descriptor of the method.
      bootstrapMethodHandle - the bootstrap method.
      bootstrapMethodArguments - the bootstrap method constant arguments. Each argument must be an Integer, Float, Long, Double, String, Type, Handle or ConstantDynamic value. This method is allowed to modify the content of the array so a caller should expect that this array may change.
      Returns:
      the new name of the method.
    • mapRecordComponentName

      public String mapRecordComponentName(String owner, String name, String descriptor)
      Maps a record component name to its new name. The default implementation of this method returns the given name, unchanged. Subclasses can override.
      Parameters:
      owner - the internal name of the owner class of the field (see Type.getInternalName()).
      name - the name of the field.
      descriptor - the descriptor of the field.
      Returns:
      the new name of the field.
    • mapFieldName

      public String mapFieldName(String owner, String name, String descriptor)
      Maps a field name to its new name. The default implementation of this method returns the given name, unchanged. Subclasses can override.
      Parameters:
      owner - the internal name of the owner class of the field (see Type.getInternalName()).
      name - the name of the field.
      descriptor - the descriptor of the field.
      Returns:
      the new name of the field.
    • mapPackageName

      public String mapPackageName(String name)
      Maps a package name to its new name. The default implementation of this method returns the given name, unchanged. Subclasses can override.
      Parameters:
      name - the fully qualified name of the package (using dots).
      Returns:
      the new name of the package.
    • mapModuleName

      public String mapModuleName(String name)
      Maps a module name to its new name. The default implementation of this method returns the given name, unchanged. Subclasses can override.
      Parameters:
      name - the fully qualified name (using dots) of a module.
      Returns:
      the new name of the module.
    • map

      public String map(String internalName)
      Maps the internal name of a class to its new name. The default implementation of this method returns the given name, unchanged. Subclasses can override.
      Parameters:
      internalName - the internal name of a class (see Type.getInternalName()).
      Returns:
      the new internal name (see Type.getInternalName()).