Interface MethodRewriteRule

All Superinterfaces:
RewriteRule
All Known Subinterfaces:
GeneratedStaticRewrite, OwnableMethodRewriteRule, OwnableMethodRewriteRule.Filtered, StaticRewrite, TargetedTypeGeneratedStaticRewrite, TargetedTypeGeneratedStaticRewrite.Parameter, TargetedTypeGeneratedStaticRewrite.Return
All Known Implementing Classes:
DirectParameterRewrite, DirectReturnRewrite, DirectStaticRewrite, FuzzyParameterRewrite, MoveInstanceMethod, SubTypeReturnRewrite, SuperTypeParamRewrite

public interface MethodRewriteRule extends RewriteRule
  • Field Details

  • Method Details

    • shouldProcess

      boolean shouldProcess(ClassProcessingContext context, int opcode, String owner, String name, String descriptor, boolean isInterface, boolean isInvokeDynamic)
      Checks if this rule should even attempt to create a MethodRewrite for the current context. Returning true here does not mean a MethodRewrite will be created, but it's an early exit for rules that know they won't be able to rewrite the method.
      Parameters:
      context - the current context
      opcode - the method opcode
      owner - the method owner (with slashes)
      name - the method name
      descriptor - the method descriptor
      isInterface - if the owning class is an interface
      isInvokeDynamic - if the method call is from an invokedynamic instruction
      Returns:
      true to continue processing the instruction
    • rewrite

      @Nullable MethodRewrite<?> rewrite(ClassProcessingContext context, boolean isInvokeDynamic, int opcode, ClassDesc owner, String name, MethodTypeDesc descriptor, boolean isInterface)
      Creates a MethodRewrite which will be applied to the processed bytecode.
      Parameters:
      context - the current context
      isInvokeDynamic - if this is in an invokedynamic instruction
      opcode - the opcode of the invoke instruction or the invokedynamic handle tag
      owner - the owner of the invoke method or the owner of the invokedynamic handle
      name - the name of the invoke method or the name of the invokedynamic handle
      descriptor - the descriptor of the invoke method or the descriptor of the invokedynamic handle
      isInterface - if the method is an interface method
      Returns:
      the rewrite or null if no rewrite should be applied
    • createVisitor

      default ClassVisitor createVisitor(int api, ClassVisitor parent, ClassProcessingContext context)
      Specified by:
      createVisitor in interface RewriteRule