Package org.spongepowered.asm.mixin.injection.invoke

## Class RedirectInjector

- java.lang.Object
- - org.spongepowered.asm.mixin.injection.code.Injector
  - - org.spongepowered.asm.mixin.injection.invoke.InvokeInjector
    - - org.spongepowered.asm.mixin.injection.invoke.RedirectInjector

Direct Known Subclasses:
  `ModifyConstantInjector`

    public class RedirectInjector
    extends InvokeInjector

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 method
>        boolean 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

Fields
`protected org.spongepowered.asm.mixin.injection.invoke.RedirectInjector.Meta` `meta` Meta is used to decorate the target node with information about this injection

### Fields inherited from class org.spongepowered.asm.mixin.injection.code.Injector

`annotationType, classNode, info, isInterface, isStatic, logger, methodArgs, methodNode, returnType`

### Constructor Summary

Constructors
`` `RedirectInjector​(InjectionInfo info)`
`protected` `RedirectInjector​(InjectionInfo info, java.lang.String annotationType)`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `addTargetNode​(InjectorTarget injectorTarget, java.util.List<InjectionNodes.InjectionNode> myNodes, org.objectweb.asm.tree.AbstractInsnNode insn, java.util.Set<InjectionPoint> nominators)`
`protected void` `checkTarget​(Target target)` Sanity checks on target
`protected void` `inject​(Target target, InjectionNodes.InjectionNode node)`
`protected void` `injectAtConstructor​(Target target, InjectionNodes.InjectionNode node)`
`protected void` `injectAtInstanceOf​(Target target, org.objectweb.asm.tree.TypeInsnNode typeNode)`
`protected void` `injectAtInstanceOf​(Target target, InjectionNodes.InjectionNode node)`
`protected void` `injectAtInvoke​(Target target, InjectionNodes.InjectionNode node)` Redirect a method invocation
`protected void` `postInject​(Target target, InjectionNodes.InjectionNode node)`
`protected boolean` `preInject​(InjectionNodes.InjectionNode node)`

### Methods inherited from class org.spongepowered.asm.mixin.injection.invoke.InvokeInjector

`sanityCheck`

### Methods 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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### meta

    protected org.spongepowered.asm.mixin.injection.invoke.RedirectInjector.Meta meta

Meta is used to decorate the target node with information about this injection

### Constructor Detail

#### RedirectInjector

    public RedirectInjector​(InjectionInfo info)

Parameters:
  `info` - Injection info

#### RedirectInjector

    protected RedirectInjector​(InjectionInfo info,
                               java.lang.String annotationType)

### Method Detail

#### checkTarget

    protected void checkTarget​(Target target)

Description copied from class: `InvokeInjector`
Sanity checks on target

Overrides:
  `checkTarget` in class `InvokeInjector`
Parameters:
  `target` - target

#### addTargetNode

    protected void addTargetNode​(InjectorTarget injectorTarget,
                                 java.util.List<InjectionNodes.InjectionNode> myNodes,
                                 org.objectweb.asm.tree.AbstractInsnNode insn,
                                 java.util.Set<InjectionPoint> nominators)

Overrides:
  `addTargetNode` in class `Injector`

#### inject

    protected void inject​(Target target,
                          InjectionNodes.InjectionNode node)

Overrides:
  `inject` in class `InvokeInjector`

#### preInject

    protected boolean preInject​(InjectionNodes.InjectionNode node)

#### postInject

    protected void postInject​(Target target,
                              InjectionNodes.InjectionNode node)

Overrides:
  `postInject` in class `Injector`

#### injectAtInvoke

    protected void injectAtInvoke​(Target target,
                                  InjectionNodes.InjectionNode node)

Redirect a method invocation

Specified by:
  `injectAtInvoke` in class `InvokeInjector`
Parameters:
  `target` - Target to inject into
  `node` - Discovered instruction node

#### injectAtConstructor

    protected void injectAtConstructor​(Target target,
                                       InjectionNodes.InjectionNode node)

#### injectAtInstanceOf

    protected void injectAtInstanceOf​(Target target,
                                      InjectionNodes.InjectionNode node)

#### injectAtInstanceOf

    protected void injectAtInstanceOf​(Target target,
                                      org.objectweb.asm.tree.TypeInsnNode typeNode)