Class 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.