public class CodeInjector
extends java.lang.Object
InjectedArgument interface, to
the specified target method at an offset determined by the implementation of the InjectStrategy interface.
Example usage: new CodeInjector() .injectInvokeStatic(logUtilClass, logDebugMethod, new
ConstantPrimitive
| Modifier and Type | Class and Description |
|---|---|
static class |
CodeInjector.ClassMethodPair |
| Constructor and Description |
|---|
CodeInjector() |
| Modifier and Type | Method and Description |
|---|---|
CodeInjector |
at(InjectStrategy injectStrategy)
Specify the location in which the invoke instruction should be injected into.
|
void |
commit()
Apply the invoke instruction in accordance to the specifications provided via the
`.injectInvokeStatic(...)`, `.into(...)` and `.at(...)` methods.
|
java.util.List<InjectedArgument> |
getArguments() |
CodeInjector.ClassMethodPair |
getContent() |
InjectStrategy |
getInjectStrategy() |
protected LocalVariable |
getResultLocalIndex() |
java.util.List<CodeInjector.ClassMethodPair> |
getTargets() |
CodeInjector |
injectInvokeStatic(Clazz clazz,
Method method)
Specify the static method to be invoked.
|
CodeInjector |
injectInvokeStatic(Clazz clazz,
Method method,
InjectedArgument... arguments)
Specify the static method to be invoked.
|
CodeInjector |
into(ProgramClass programClass,
ProgramMethod programMethod)
Specify the method where a static method invocation will be injected into.
|
boolean |
readyToCommit() |
LocalVariable |
store() |
public CodeInjector injectInvokeStatic(Clazz clazz, Method method)
clazz - The class containing the static method to be invoked.method - The method to be invoked.public CodeInjector injectInvokeStatic(Clazz clazz, Method method, InjectedArgument... arguments)
clazz - The class containing the static method to be invoked.method - The method to be invoked.arguments - A list of arguments to be passed to the method to be invoked.public CodeInjector into(ProgramClass programClass, ProgramMethod programMethod)
programClass - The program class that has the method where a static method invocation will
be injected into.programMethod - The method where a static method invocation will be injected into.public CodeInjector at(InjectStrategy injectStrategy)
injectStrategy - The implementation of the InjectStrategy interface which determines the
offset to inject the invoke instruction.public LocalVariable store()
public void commit()
public boolean readyToCommit()
public java.util.List<CodeInjector.ClassMethodPair> getTargets()
public CodeInjector.ClassMethodPair getContent()
public InjectStrategy getInjectStrategy()
public java.util.List<InjectedArgument> getArguments()
protected LocalVariable getResultLocalIndex()