Record Class MoveInstanceMethod

java.lang.Object
java.lang.Record
io.papermc.asm.rules.method.MoveInstanceMethod
All Implemented Interfaces:
GeneratedMethodHolder, GeneratedStaticRewrite, MethodRewriteRule, OwnableMethodRewriteRule, OwnableMethodRewriteRule.Filtered, StaticRewrite, OwnableRewriteRule, RewriteRule

public record MoveInstanceMethod(Set<ClassDesc> owners, MethodMatcher methodMatcher, ClassDesc newOwner, String newMethodName) extends Record implements GeneratedStaticRewrite, OwnableMethodRewriteRule.Filtered
Generally used to move a method from an interface to its implementation class. This is useful when the API has a changed method, but you still want the exact behavior of the original method. Just keep the original in the implementation and redirect to the implementation.
  • Constructor Details

    • MoveInstanceMethod

      public MoveInstanceMethod(Set<ClassDesc> owners, MethodMatcher methodMatcher, ClassDesc newOwner, String newMethodName)
      Creates an instance of a MoveInstanceMethod record class.
      Parameters:
      owners - the value for the owners record component
      methodMatcher - the value for the methodMatcher record component
      newOwner - the value for the newOwner record component
      newMethodName - the value for the newMethodName record component
  • Method Details

    • rewrite

      public @Nullable MethodRewrite<?> rewrite(ClassProcessingContext context, boolean isInvokeDynamic, int opcode, ClassDesc owner, String name, MethodTypeDesc descriptor, boolean isInterface)
      Description copied from interface: MethodRewriteRule
      Creates a MethodRewrite which will be applied to the processed bytecode.
      Specified by:
      rewrite in interface MethodRewriteRule
      Specified by:
      rewrite in interface StaticRewrite
      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
    • generateMethod

      Description copied from interface: GeneratedMethodHolder
      Generates a method with the provided information.
      Specified by:
      generateMethod in interface GeneratedMethodHolder
      Parameters:
      factory - the factory for method generation
      modified - the method call information that replaced the matching method in bytecode
      original - the original method that was matched in the bytecode
    • generateConstructor

      Specified by:
      generateConstructor in interface GeneratedMethodHolder
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • owners

      public Set<ClassDesc> owners()
      Returns the value of the owners record component.
      Specified by:
      owners in interface OwnableRewriteRule
      Returns:
      the value of the owners record component
    • methodMatcher

      public MethodMatcher methodMatcher()
      Returns the value of the methodMatcher record component.
      Specified by:
      methodMatcher in interface OwnableMethodRewriteRule.Filtered
      Returns:
      the value of the methodMatcher record component
    • newOwner

      public ClassDesc newOwner()
      Returns the value of the newOwner record component.
      Returns:
      the value of the newOwner record component
    • newMethodName

      public String newMethodName()
      Returns the value of the newMethodName record component.
      Returns:
      the value of the newMethodName record component