Class MixinTransformer

java.lang.Object
org.spongepowered.asm.transformers.TreeTransformer
org.spongepowered.asm.mixin.transformer.MixinTransformer
All Implemented Interfaces:
IMixinTransformer, ILegacyClassTransformer, ITransformer

public final class MixinTransformer extends TreeTransformer implements IMixinTransformer
Transformer which manages the mixin configuration and application process
  • Method Details

    • getExtensions

      public IExtensionRegistry getExtensions()
      Description copied from interface: IMixinTransformer
      Get the transformer extensions
      Specified by:
      getExtensions in interface IMixinTransformer
    • getName

      public String getName()
      Description copied from interface: ITransformer
      Get the identifier for this transformer, usually the class name but for wrapped transformers this is the class name of the wrapped transformer
      Specified by:
      getName in interface ITransformer
      Returns:
      transformer's identifying name
    • isDelegationExcluded

      public boolean isDelegationExcluded()
      Description copied from interface: ITransformer
      Get whether this transformer is excluded from delegation. Some transformers (such as the mixin transformer itself) should not be included in the delegation list because they are re-entrant or do not need to run on incoming bytecode.
      Specified by:
      isDelegationExcluded in interface ITransformer
      Returns:
      true if this transformer should be excluded from the transformer delegation list
    • audit

      public void audit(MixinEnvironment environment)
      Run audit process on current mixin processor
      Specified by:
      audit in interface IMixinTransformer
      Parameters:
      environment - Environment for audit
    • reload

      public List<String> reload(String mixinClass, org.objectweb.asm.tree.ClassNode classNode)
      Callback from hotswap agent
      Specified by:
      reload in interface IMixinTransformer
      Parameters:
      mixinClass - Name of the mixin
      classNode - New class
      Returns:
      List of classes that need to be updated
    • transformClassBytes

      public byte[] transformClassBytes(String name, String transformedName, byte[] basicClass)
      Description copied from interface: IMixinTransformer
      Callback from the hotswap agent and LaunchWrapper Proxy, transform class bytecode. This method delegates to class generation or class transformation based on whether the supplied byte array is null and is therefore suitable for hosts which follow the LaunchWrapper contract.
      Specified by:
      transformClassBytes in interface ILegacyClassTransformer
      Specified by:
      transformClassBytes in interface IMixinTransformer
      Parameters:
      name - Class name
      transformedName - Transformed class name
      basicClass - class bytecode
      Returns:
      transformed class bytecode
      See Also:
    • computeFramesForClass

      public boolean computeFramesForClass(MixinEnvironment environment, String name, org.objectweb.asm.tree.ClassNode classNode)
      Called when the transformation reason is computing_frames. The only operation we care about here is adding interfaces to target classes but at the moment we don't have sufficient scaffolding to determine that without triggering re-entrance. Currently just a no-op in order to not cause a re-entrance crash under ModLauncher 7.0+.
      Specified by:
      computeFramesForClass in interface IMixinTransformer
      Parameters:
      environment - Current environment
      name - Class transformed name
      classNode - Class tree
      Returns:
      true if the class was transformed
    • transformClass

      public byte[] transformClass(MixinEnvironment environment, String name, byte[] classBytes)
      Apply mixins and postprocessors to the supplied class
      Specified by:
      transformClass in interface IMixinTransformer
      Parameters:
      environment - Current environment
      name - Class transformed name
      classBytes - Class bytecode
      Returns:
      Transformed bytecode
    • transformClass

      public boolean transformClass(MixinEnvironment environment, String name, org.objectweb.asm.tree.ClassNode classNode)
      Apply mixins and postprocessors to the supplied class
      Specified by:
      transformClass in interface IMixinTransformer
      Parameters:
      environment - Current environment
      name - Class transformed name
      classNode - Class tree
      Returns:
      true if the class was transformed
    • couldTransformClass

      public boolean couldTransformClass(MixinEnvironment environment, String name)
      Determines whether mixin could transform the provided class, without actually running the transformation
      Specified by:
      couldTransformClass in interface IMixinTransformer
      Parameters:
      environment - Current environment
      name - Class transformed name
      Returns:
      true if the class could be transformed
    • generateClass

      public byte[] generateClass(MixinEnvironment environment, String name)
      Generate the specified mixin-synthetic class
      Specified by:
      generateClass in interface IMixinTransformer
      Parameters:
      environment - Current environment
      name - Class name to generate
      Returns:
      Generated bytecode or null if no class was generated
    • generateClass

      public boolean generateClass(MixinEnvironment environment, String name, org.objectweb.asm.tree.ClassNode classNode)
      Specified by:
      generateClass in interface IMixinTransformer
      Parameters:
      environment - Current environment
      name - Class transformed name
      classNode - Empty classnode to populate
      Returns:
      True if the class was generated successfully