类 CodeInjector
- java.lang.Object
-
- proguard.classfile.util.inject.CodeInjector
-
- 直接已知子类:
AccumulatedCodeInjector
public class CodeInjector extends java.lang.ObjectThis utility class allows for injecting a method invocation instruction, optionally with arguments modeled by instances of classes implementing theInjectedArgumentinterface, to the specified target method at an offset determined by the implementation of theInjectStrategyinterface.Example usage: new CodeInjector() .injectInvokeStatic(logUtilClass, logDebugMethod, new ConstantPrimitive
(1), new ConstantString("Hello world")) .into(MainProgramClass, mainMethod) .at(new FirstBlock()) .commit();
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static classCodeInjector.ClassMethodPair
-
字段概要
字段 修饰符和类型 字段 说明 protected CodeAttributeEditoreditor
-
构造器概要
构造器 构造器 说明 CodeInjector()已过时。UseCodeInjector(CodeAttributeEditor)instead.CodeInjector(CodeAttributeEditor editor)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 CodeInjectorat(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.java.util.List<InjectedArgument>getArguments()CodeInjector.ClassMethodPairgetContent()InjectStrategygetInjectStrategy()protected LocalVariablegetResultLocalIndex()java.util.List<CodeInjector.ClassMethodPair>getTargets()CodeInjectorinjectInvokeStatic(Clazz clazz, Method method)Specify the static method to be invoked.CodeInjectorinjectInvokeStatic(Clazz clazz, Method method, InjectedArgument... arguments)Specify the static method to be invoked.CodeInjectorinto(ProgramClass programClass, ProgramMethod programMethod)Specify the method where a static method invocation will be injected into.booleanreadyToCommit()voidreset()Resets the internal state of this injector, allowing it to be reused.LocalVariablestore()
-
-
-
字段详细资料
-
editor
protected final CodeAttributeEditor editor
-
-
构造器详细资料
-
CodeInjector
@Deprecated public CodeInjector()
已过时。UseCodeInjector(CodeAttributeEditor)instead.
-
CodeInjector
public CodeInjector(CodeAttributeEditor editor)
-
-
方法详细资料
-
injectInvokeStatic
public CodeInjector injectInvokeStatic(Clazz clazz, Method method)
Specify the static method to be invoked.- 参数:
clazz- The class containing the static method to be invoked.method- The method to be invoked.
-
injectInvokeStatic
public CodeInjector injectInvokeStatic(Clazz clazz, Method method, InjectedArgument... arguments)
Specify the static method to be invoked.- 参数:
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
public CodeInjector into(ProgramClass programClass, ProgramMethod programMethod)
Specify the method where a static method invocation will be injected into.- 参数:
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
public CodeInjector at(InjectStrategy injectStrategy)
Specify the location in which the invoke instruction should be injected into.- 参数:
injectStrategy- The implementation of the InjectStrategy interface which determines the offset to inject the invoke instruction.
-
store
public LocalVariable 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
public java.util.List<CodeInjector.ClassMethodPair> getTargets()
-
getContent
public CodeInjector.ClassMethodPair getContent()
-
getInjectStrategy
public InjectStrategy getInjectStrategy()
-
getArguments
public java.util.List<InjectedArgument> getArguments()
-
getResultLocalIndex
protected LocalVariable getResultLocalIndex()
-
-