-
public abstract class MethodReplacement extends MethodHook
Like MethodHook but replaces the whole method call. Use this will always prevent the original method call and remaining hooks to be invoked expect you manually call them. Make sure you are sure you really want this!
-
-
Field Summary
Fields Modifier and Type Field Description public final static MethodReplacementDO_NOTHING
-
Method Summary
Modifier and Type Method Description final voidbeforeCall(Pine.CallFrame callFrame)Invoked before the method gets called. final voidafterCall(Pine.CallFrame callFrame)Invoked after the method gets called. static MethodReplacementreturnConstant(Object result)Helper function to create an replacement instance when you just want to return a constant value. -
-
Method Detail
-
beforeCall
final void beforeCall(Pine.CallFrame callFrame)
Invoked before the method gets called. You can get or modify some info about this call by the given
{@code callFrame}.Note that setting result or exception will prevent the original method call, and next hooks won'tbe called. Throwing any exception in this method will cause the result or exception you setgets reset, if you want to set an exception as the method thrown, use setThrowable- Parameters:
callFrame- object that stores some info about info call.
-
afterCall
final void afterCall(Pine.CallFrame callFrame)
Invoked after the method gets called. You can get or modify some info about this call by the given
{@code callFrame}.Throwing any exception in this method will cause the result or exception you set gets reset.If you want to set an exception as the method thrown, use setThrowable- Parameters:
callFrame- object that stores some info about info call.
-
returnConstant
static MethodReplacement returnConstant(Object result)
Helper function to create an replacement instance when you just want to return a constant value.
- Parameters:
result- The value you want to return
-
-
-
-