Package proguard.classfile.util.inject
Class CodeInjector
java.lang.Object
proguard.classfile.util.inject.CodeInjector
- Direct Known Subclasses:
AccumulatedCodeInjector
This utility class allows for injecting a method invocation instruction, optionally with
arguments modeled by instances of classes implementing the
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
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionat(InjectStrategy injectStrategy) Specify the location in which the invoke instruction should be injected into.voidcommit()Apply the invoke instruction in accordance to the specifications provided via the `.injectInvokeStatic(...)`, `.into(...)` and `.at(...)` methods.protected LocalVariableinjectInvokeStatic(Clazz clazz, Method method) Specify the static method to be invoked.injectInvokeStatic(Clazz clazz, Method method, InjectedArgument... arguments) Specify the static method to be invoked.into(ProgramClass programClass, ProgramMethod programMethod) Specify the method where a static method invocation will be injected into.booleanvoidreset()Resets the internal state of this injector, allowing it to be reused.store()
-
Field Details
-
editor
-
-
Constructor Details
-
CodeInjector
Deprecated.UseCodeInjector(CodeAttributeEditor)instead. -
CodeInjector
-
-
Method Details
-
injectInvokeStatic
Specify the static method to be invoked.- Parameters:
clazz- The class containing the static method to be invoked.method- The method to be invoked.
-
injectInvokeStatic
Specify the static method to be invoked.- Parameters:
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.
-
reset
public void reset()Resets the internal state of this injector, allowing it to be reused.This avoids the performance overhead of re-instantiating the attribute editor for subsequent operations.
-
into
Specify the method where a static method invocation will be injected into.- Parameters:
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.
-
at
Specify the location in which the invoke instruction should be injected into.- Parameters:
injectStrategy- The implementation of the InjectStrategy interface which determines the offset to inject the invoke instruction.
-
store
-
commit
public void commit()Apply the invoke instruction in accordance to the specifications provided via the `.injectInvokeStatic(...)`, `.into(...)` and `.at(...)` methods. -
readyToCommit
public boolean readyToCommit() -
getTargets
-
getContent
-
getInjectStrategy
-
getArguments
-
getResultLocalIndex
-
CodeInjector(CodeAttributeEditor)instead.