Record Class SimpleRewrite
java.lang.Object
java.lang.Record
io.papermc.asm.rules.method.rewrite.SimpleRewrite
- Record Components:
opcode- the replaced opcodeowner- the replaced ownername- the replaced namedescriptor- the replaced descriptorisInterface- if the replaced method is an interface methodisInvokeDynamic- if the replaced method is an invokedynamicgeneratorInfo- info for generating the method (optional)
- All Implemented Interfaces:
MethodRewrite<GeneratedMethodHolder.MethodCallData>
public record SimpleRewrite(int opcode, ClassDesc owner, String name, MethodTypeDesc descriptor, boolean isInterface, boolean isInvokeDynamic, @Nullable MethodRewrite.GeneratorInfo<GeneratedMethodHolder.MethodCallData> generatorInfo, @Nullable Consumer<Object[]> handleExtras)
extends Record
implements MethodRewrite<GeneratedMethodHolder.MethodCallData>
Holds the structure of the rewritten method that replaces a matching method found in the bytecode. This
is for non-constructors. For constructors, use
ConstructorRewrite.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.papermc.asm.rules.method.rewrite.MethodRewrite
MethodRewrite.GeneratorInfo<D extends GeneratedMethodHolder.CallData>, MethodRewrite.MethodGenerator -
Field Summary
Fields inherited from interface io.papermc.asm.rules.method.rewrite.MethodRewrite
BOOTSTRAP_HANDLE_IDX, DYNAMIC_TYPE_IDX, GENERATED_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionSimpleRewrite(int opcode, ClassDesc owner, String name, MethodTypeDesc descriptor, boolean isInterface, boolean isInvokeDynamic) SimpleRewrite(int opcode, ClassDesc owner, String name, MethodTypeDesc descriptor, boolean isInterface, boolean isInvokeDynamic, @Nullable MethodRewrite.GeneratorInfo<GeneratedMethodHolder.MethodCallData> generatorInfo, @Nullable Consumer<Object[]> handleExtras) Creates an instance of aSimpleRewriterecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(MethodVisitor delegate, MethodNode context) Called to apply the rewrite when a matching invoke non-dynamic instruction is found.voidapplyToBootstrapArguments(Object[] arguments) Called to apply the rewrite to a matching invokedynamic instruction is found.Creates aMethodRewrite.MethodGeneratorfor this rewrite.Returns the value of thedescriptorrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thegeneratorInforecord component.Returns the value of thehandleExtrasrecord component.final inthashCode()Returns a hash code value for this object.booleanReturns the value of theisInterfacerecord component.booleanReturns the value of theisInvokeDynamicrecord component.name()Returns the value of thenamerecord component.intopcode()Returns the value of theopcoderecord component.owner()Returns the value of theownerrecord component.final StringtoString()Returns a string representation of this record class.withGeneratorInfo(GeneratedMethodHolder holder, GeneratedMethodHolder.MethodCallData original) Creates a newMethodRewritewith the given generator info.withHandleExtras(Consumer<Object[]> extras) Creates a newMethodRewritewith the given "extras" handler.
-
Constructor Details
-
SimpleRewrite
public SimpleRewrite(int opcode, ClassDesc owner, String name, MethodTypeDesc descriptor, boolean isInterface, boolean isInvokeDynamic) -
SimpleRewrite
public SimpleRewrite(int opcode, ClassDesc owner, String name, MethodTypeDesc descriptor, boolean isInterface, boolean isInvokeDynamic, @Nullable MethodRewrite.GeneratorInfo<GeneratedMethodHolder.MethodCallData> generatorInfo, @Nullable Consumer<Object[]> handleExtras) Creates an instance of aSimpleRewriterecord class.- Parameters:
opcode- the value for theopcoderecord componentowner- the value for theownerrecord componentname- the value for thenamerecord componentdescriptor- the value for thedescriptorrecord componentisInterface- the value for theisInterfacerecord componentisInvokeDynamic- the value for theisInvokeDynamicrecord componentgeneratorInfo- the value for thegeneratorInforecord componenthandleExtras- the value for thehandleExtrasrecord component
-
-
Method Details
-
apply
Description copied from interface:MethodRewriteCalled to apply the rewrite when a matching invoke non-dynamic instruction is found.- Specified by:
applyin interfaceMethodRewrite<GeneratedMethodHolder.MethodCallData>- Parameters:
delegate- the visitor to apply the change tocontext- the surrounding context of the method's data including instructions
-
applyToBootstrapArguments
Description copied from interface:MethodRewriteCalled to apply the rewrite to a matching invokedynamic instruction is found.- Specified by:
applyToBootstrapArgumentsin interfaceMethodRewrite<GeneratedMethodHolder.MethodCallData>- Parameters:
arguments- the bootstrap argumentsMethodVisitor.visitInvokeDynamicInsn(String, String, Handle, Object...)
-
withGeneratorInfo
public MethodRewrite<GeneratedMethodHolder.MethodCallData> withGeneratorInfo(GeneratedMethodHolder holder, GeneratedMethodHolder.MethodCallData original) Description copied from interface:MethodRewriteCreates a newMethodRewritewith the given generator info.- Specified by:
withGeneratorInfoin interfaceMethodRewrite<GeneratedMethodHolder.MethodCallData>- Parameters:
holder- the generator holderoriginal- the original call data- Returns:
- the new rewrite
-
withHandleExtras
public MethodRewrite<GeneratedMethodHolder.MethodCallData> withHandleExtras(Consumer<Object[]> extras) Description copied from interface:MethodRewriteCreates a newMethodRewritewith the given "extras" handler. This is when extra changes are required for invokedynamic instructions.- Specified by:
withHandleExtrasin interfaceMethodRewrite<GeneratedMethodHolder.MethodCallData>- Parameters:
extras- the extras handler- Returns:
- the new rewrite (or the same if not supported on the rewrite type)
-
createMethodGenerator
Description copied from interface:MethodRewriteCreates aMethodRewrite.MethodGeneratorfor this rewrite.- Specified by:
createMethodGeneratorin interfaceMethodRewrite<GeneratedMethodHolder.MethodCallData>- Returns:
- a method generator, or null if this rewrite doesn't have one
- See Also:
-
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. -
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. -
equals
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
opcode
public int opcode()Returns the value of theopcoderecord component.- Returns:
- the value of the
opcoderecord component
-
owner
Returns the value of theownerrecord component.- Returns:
- the value of the
ownerrecord component
-
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
descriptor
Returns the value of thedescriptorrecord component.- Returns:
- the value of the
descriptorrecord component
-
isInterface
public boolean isInterface()Returns the value of theisInterfacerecord component.- Returns:
- the value of the
isInterfacerecord component
-
isInvokeDynamic
public boolean isInvokeDynamic()Returns the value of theisInvokeDynamicrecord component.- Returns:
- the value of the
isInvokeDynamicrecord component
-
generatorInfo
Returns the value of thegeneratorInforecord component.- Returns:
- the value of the
generatorInforecord component
-
handleExtras
Returns the value of thehandleExtrasrecord component.- Returns:
- the value of the
handleExtrasrecord component
-