Class RedirectInjector
- Direct Known Subclasses:
ModifyConstantInjector
A bytecode injector which allows a method call, field access or
new object creation to be redirected to the annotated handler
method. For method redirects, the handler method signature must match the
hooked method precisely but prepended with an arg of the owning
object's type to accept the object instance the method was going to be
invoked upon. For more details see the javadoc for the @Redirect annotation.
For example when hooking the following call:
int abc = 0; int def = 1; Foo someObject = new Foo();// Hooking this methodboolean xyz = someObject.bar(abc, def);
The signature of the redirected method should be:
public boolean barProxy(Foo someObject, int abc, int def)
For obvious reasons this does not apply for static methods, for static methods it is sufficient that the signature simply match the hooked method.
For field redirections, see the details in @Redirect
for the required signature of the handler method.
For constructor redirections, the signature of the handler method should match the constructor itself, return type should be of the type of object being created.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.spongepowered.asm.mixin.injection.code.Injector
Injector.InjectorData, Injector.TargetNode -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.spongepowered.asm.mixin.injection.invoke.RedirectInjector.MetaMeta is used to decorate the target node with information about this injectionFields inherited from class org.spongepowered.asm.mixin.injection.code.Injector
annotationType, classNode, info, isInterface, isStatic, logger, methodArgs, methodNode, returnType -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRedirectInjector(InjectionInfo info, String annotationType) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddTargetNode(InjectorTarget injectorTarget, List<InjectionNodes.InjectionNode> myNodes, org.objectweb.asm.tree.AbstractInsnNode insn, Set<InjectionPoint> nominators) protected voidcheckTarget(Target target) Sanity checks on targetprotected voidinject(Target target, InjectionNodes.InjectionNode node) protected voidinjectAtConstructor(Target target, InjectionNodes.InjectionNode node) protected voidinjectAtInstanceOf(Target target, org.objectweb.asm.tree.TypeInsnNode typeNode) protected voidinjectAtInstanceOf(Target target, InjectionNodes.InjectionNode node) protected voidinjectAtInvoke(Target target, InjectionNodes.InjectionNode node) Redirect a method invocationprotected voidpostInject(Target target, InjectionNodes.InjectionNode node) protected booleanMethods inherited from class org.spongepowered.asm.mixin.injection.invoke.InvokeInjector
sanityCheckMethods inherited from class org.spongepowered.asm.mixin.injection.code.Injector
addTargetNode, canCoerce, canCoerce, canCoerce, checkCoerce, checkTargetForNode, checkTargetModifiers, find, findTargetNodes, inject, invokeHandler, invokeHandler, invokeHandlerWithArgs, invokeHandlerWithArgs, preInject, preInject, pushArgs, pushArgs, storeArgs, storeArgs, storeArgs, storeArgs, throwException, toString, validateParams
-
Field Details
-
meta
protected org.spongepowered.asm.mixin.injection.invoke.RedirectInjector.Meta metaMeta is used to decorate the target node with information about this injection
-
-
Constructor Details
-
RedirectInjector
- Parameters:
info- Injection info
-
RedirectInjector
-
-
Method Details
-
checkTarget
Description copied from class:InvokeInjectorSanity checks on target- Overrides:
checkTargetin classInvokeInjector- Parameters:
target- target
-
addTargetNode
protected void addTargetNode(InjectorTarget injectorTarget, List<InjectionNodes.InjectionNode> myNodes, org.objectweb.asm.tree.AbstractInsnNode insn, Set<InjectionPoint> nominators) - Overrides:
addTargetNodein classInjector
-
inject
- Overrides:
injectin classInvokeInjector
-
preInject
-
postInject
- Overrides:
postInjectin classInjector
-
injectAtInvoke
Redirect a method invocation- Specified by:
injectAtInvokein classInvokeInjector- Parameters:
target- Target to inject intonode- Discovered instruction node
-
injectAtConstructor
-
injectAtInstanceOf
-
injectAtInstanceOf
-