Interface ClassRemapper

All Superinterfaces:
ClassFileTransform<ClassTransform, ClassElement, ClassBuilder>, ClassTransform

public sealed interface ClassRemapper extends ClassTransform
ClassRemapper is a ClassTransform, FieldTransform, MethodTransform and CodeTransform deeply re-mapping all class references in any form, according to given map or map function.

The re-mapping is applied to superclass, interfaces, all kinds of descriptors and signatures, all attributes referencing classes in any form (including all types of annotations), and to all instructions referencing to classes.

Primitive types and arrays are never subjects of mapping and are not allowed targets of mapping.

Arrays of reference types are always decomposed, mapped as the base reference types and composed back to arrays.

Since:
24
  • Method Details

    • of

      static ClassRemapper of(Map<ClassDesc, ClassDesc> classMap)
      Creates new instance of ClassRemapper instructed with a class map. Map may contain only re-mapping entries, identity mapping is applied by default.
      Parameters:
      classMap - class map
      Returns:
      new instance of ClassRemapper
    • of

      static ClassRemapper of(Function<ClassDesc, ClassDesc> mapFunction)
      Creates new instance of ClassRemapper instructed with a map function. Map function must return valid ClassDesc of an interface or a class, even for identity mappings.
      Parameters:
      mapFunction - class map function
      Returns:
      new instance of ClassRemapper
    • map

      ClassDesc map(ClassDesc desc)
      Access method to internal class mapping function.
      Parameters:
      desc - source class
      Returns:
      target class
    • asFieldTransform

      FieldTransform asFieldTransform()
      Returns this ClassRemapper as FieldTransform instance.
      Returns:
      this ClassRemapper as FieldTransform instance
    • asMethodTransform

      MethodTransform asMethodTransform()
      Returns this ClassRemapper as MethodTransform instance.
      Returns:
      this ClassRemapper as MethodTransform instance
    • asCodeTransform

      CodeTransform asCodeTransform()
      Returns this ClassRemapper as CodeTransform instance.
      Returns:
      this ClassRemapper as CodeTransform instance
    • remapClass

      default byte[] remapClass(ClassFile context, ClassModel clm)
      Remaps the whole ClassModel into a new class file, including the class name.
      Parameters:
      context - ClassFile context
      clm - class model to re-map
      Returns:
      re-mapped class file bytes