Class Renamer


  • public class Renamer
    extends Object
    Main API for renaming classes, methods, and fields in a ClassPool.
    • Constructor Detail

      • Renamer

        public Renamer​(ClassPool classPool)
        Creates a new Renamer for the given ClassPool.
        Parameters:
        classPool - The ClassPool containing classes to rename
    • Method Detail

      • mapClass

        public Renamer mapClass​(String oldName,
                                String newName)
        Maps a class to a new name.
        Parameters:
        oldName - The old internal class name (e.g., "com/old/MyClass")
        newName - The new internal class name (e.g., "com/new/RenamedClass")
        Returns:
        this for fluent chaining
      • mapMethod

        public Renamer mapMethod​(String owner,
                                 String name,
                                 String descriptor,
                                 String newName)
        Maps a method to a new name (single class only, no hierarchy propagation).
        Parameters:
        owner - The internal name of the class owning the method
        name - The old method name
        descriptor - The method descriptor
        newName - The new method name
        Returns:
        this for fluent chaining
      • mapMethodInHierarchy

        public Renamer mapMethodInHierarchy​(String owner,
                                            String name,
                                            String descriptor,
                                            String newName)
        Maps a method to a new name with hierarchy propagation.
        Parameters:
        owner - The internal name of the class owning the method
        name - The old method name
        descriptor - The method descriptor
        newName - The new method name
        Returns:
        this for fluent chaining
      • mapField

        public Renamer mapField​(String owner,
                                String name,
                                String descriptor,
                                String newName)
        Maps a field to a new name.
        Parameters:
        owner - The internal name of the class owning the field
        name - The old field name
        descriptor - The field descriptor
        newName - The new field name
        Returns:
        this for fluent chaining
      • validate

        public ValidationResult validate()
        Validates all mappings without applying them.
        Returns:
        ValidationResult containing any errors or warnings
      • apply

        public void apply()
        Applies all rename mappings.
        Throws:
        RenameException - if validation fails or an error occurs during renaming
      • applyUnsafe

        public void applyUnsafe()
        Applies all rename mappings without validation.
      • findOverrides

        public Set<MethodEntry> findOverrides​(String owner,
                                              String name,
                                              String descriptor)
        Finds all methods that override or implement the specified method.
        Parameters:
        owner - The internal name of the class owning the method
        name - The method name
        descriptor - The method descriptor
        Returns:
        Set of MethodEntry objects that override this method
      • getMappings

        public MappingStore getMappings()
        Returns the current mapping store.
        Returns:
        The MappingStore
      • clear

        public Renamer clear()
        Clears all mappings.
        Returns:
        this for fluent chaining
      • getHierarchy

        public ClassHierarchy getHierarchy()
        Returns the class hierarchy.
        Returns:
        The ClassHierarchy