类 InstructionSequenceReplacer
- java.lang.Object
-
- proguard.classfile.editor.InstructionSequenceReplacer
-
- 所有已实现的接口:
ConstantVisitor,InstructionVisitor
public class InstructionSequenceReplacer extends java.lang.Object implements InstructionVisitor, ConstantVisitor
ThisInstructionVisitorreplaces a given pattern instruction sequence by another given replacement instruction sequence. The arguments of the instruction sequences can be wildcards that are matched and replaced.The class also supports labels (
label()) and exception handlers (catch_(int,int,int)) in replacement sequences. They provide local branch offsets inside the replacement sequences (InstructionSequenceReplacer.Label.offset()). For example, creating a replacement sequence with the help ofInstructionSequenceBuilder:final InstructionSequenceReplacer.Label TRY_START = InstructionSequenceReplacer.label(); final InstructionSequenceReplacer.Label TRY_END = InstructionSequenceReplacer.label(); final InstructionSequenceReplacer.Label CATCH_END = InstructionSequenceReplacer.label(); final InstructionSequenceReplacer.Label CATCH_EXCEPTION = InstructionSequenceReplacer.catch_(TRY_START.offset(), TRY_END.offset(), constantPoolEditor.addClassConstant("java/lang/Exception", null)); Instructions[] replacementInstructions = builder .label(TRY_START) ...... .label(TRY_END) .goto_(CATCH_END.offset()) .catch_(CATCH_EXCEPTION) ...... .athrow() .label(CATCH_END) ...... .instructions();
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static classInstructionSequenceReplacer.LabelThis pseudo-instruction represents a label that marks an instruction offset, for use in the context of the sequence replacer only.
-
字段概要
字段 修饰符和类型 字段 说明 static intAstatic intBstatic intBOOLEAN_A_STRINGstatic intBOOLEAN_B_STRINGstatic intCstatic intCHAR_A_STRINGstatic intCHAR_B_STRINGstatic intCLASS_A_NAMEstatic intCLASS_A_SIMPLE_NAMEstatic intDstatic intDOUBLE_A_STRINGstatic intDOUBLE_B_STRINGstatic intEstatic intFstatic intFLOAT_A_STRINGstatic intFLOAT_B_STRINGstatic intGstatic intHstatic intIstatic intINT_A_STRINGstatic intINT_B_STRINGstatic intJstatic intKstatic intLstatic intLONG_A_STRINGstatic intLONG_B_STRINGstatic intMstatic intNstatic intOstatic intPstatic intQstatic intRstatic intSTRING_A_LENGTHstatic intSTRING_A_STRINGstatic intSTRING_B_STRINGstatic intXstatic intYstatic intZ
-
构造器概要
构造器 限定符 构造器 说明 InstructionSequenceReplacer(Constant[] patternConstants, Instruction[] patternInstructions, Constant[] replacementConstants, Instruction[] replacementInstructions, BranchTargetFinder branchTargetFinder, CodeAttributeEditor codeAttributeEditor)Creates a new InstructionSequenceReplacer.InstructionSequenceReplacer(Constant[] patternConstants, Instruction[] patternInstructions, Constant[] replacementConstants, Instruction[] replacementInstructions, BranchTargetFinder branchTargetFinder, CodeAttributeEditor codeAttributeEditor, InstructionVisitor extraInstructionVisitor)Creates a new InstructionSequenceReplacer.InstructionSequenceReplacer(InstructionSequenceMatcher instructionSequenceMatcher, Constant[] patternConstants, Instruction[] patternInstructions, Constant[] replacementConstants, Instruction[] replacementInstructions, BranchTargetFinder branchTargetFinder, CodeAttributeEditor codeAttributeEditor, InstructionVisitor extraInstructionVisitor)protectedInstructionSequenceReplacer(InstructionSequenceMatcher instructionSequenceMatcher, Constant[] replacementConstants, Instruction[] replacementInstructions, BranchTargetFinder branchTargetFinder, CodeAttributeEditor codeAttributeEditor, InstructionVisitor extraInstructionVisitor)Creates a new InstructionSequenceReplacer.
-
方法概要
所有方法 静态方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 static InstructionSequenceReplacer.Labelcatch_(int startOffset, int endOffset, int catchType)Creates a new catch instance that can be used as a pseudo-instruction to mark the start of an exception handler.protected InstructionSequenceMatchergetInstructionSequenceMatcher()static InstructionSequenceReplacer.Labellabel()Creates a new label that can be used as a pseudo-instruction to mark a local offset.protected intmatchedArgument(int argument)protected intmatchedArgument(Clazz clazz, int argument)Returns the matched argument for the given pattern argument.protected intmatchedArgument(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int argument)Returns the matched argument for the given pattern argument.protected intmatchedBranchOffset(int offset, int branchOffset)Returns the value of the specified matched branch offset.protected ConstantmatchedConstant(ProgramClass programClass, int argument)protected intmatchedConstantIndex(ProgramClass programClass, int constantIndex)已过时。protected intmatchedConstantIndex(ProgramClass programClass, ProgramMethod programMethod, int constantIndex)Returns the matched or newly created constant index for the given pattern constant index.protected int[]matchedJumpOffsets(int offset, int[] jumpOffsets)Returns the values of the specified matched jump offsets.voidvisitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction)Visits any Instruction instance.protected booleanwasConstant(int argument)-
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
从接口继承的方法 proguard.classfile.constant.visitor.ConstantVisitor
visitAnyConstant, visitAnyMethodrefConstant, visitAnyRefConstant, visitClassConstant, visitDoubleConstant, visitDynamicConstant, visitFieldrefConstant, visitFloatConstant, visitIntegerConstant, visitInterfaceMethodrefConstant, visitInvokeDynamicConstant, visitLongConstant, visitMethodHandleConstant, visitMethodrefConstant, visitMethodTypeConstant, visitModuleConstant, visitNameAndTypeConstant, visitPackageConstant, visitPrimitiveArrayConstant, visitStringConstant, visitUtf8Constant
-
从接口继承的方法 proguard.classfile.instruction.visitor.InstructionVisitor
visitAnySwitchInstruction, visitBranchInstruction, visitConstantInstruction, visitLookUpSwitchInstruction, visitSimpleInstruction, visitTableSwitchInstruction, visitVariableInstruction
-
-
-
-
字段详细资料
-
X
public static final int X
- 另请参阅:
- 常量字段值
-
Y
public static final int Y
- 另请参阅:
- 常量字段值
-
Z
public static final int Z
- 另请参阅:
- 常量字段值
-
A
public static final int A
- 另请参阅:
- 常量字段值
-
B
public static final int B
- 另请参阅:
- 常量字段值
-
C
public static final int C
- 另请参阅:
- 常量字段值
-
D
public static final int D
- 另请参阅:
- 常量字段值
-
E
public static final int E
- 另请参阅:
- 常量字段值
-
F
public static final int F
- 另请参阅:
- 常量字段值
-
G
public static final int G
- 另请参阅:
- 常量字段值
-
H
public static final int H
- 另请参阅:
- 常量字段值
-
I
public static final int I
- 另请参阅:
- 常量字段值
-
J
public static final int J
- 另请参阅:
- 常量字段值
-
K
public static final int K
- 另请参阅:
- 常量字段值
-
L
public static final int L
- 另请参阅:
- 常量字段值
-
M
public static final int M
- 另请参阅:
- 常量字段值
-
N
public static final int N
- 另请参阅:
- 常量字段值
-
O
public static final int O
- 另请参阅:
- 常量字段值
-
P
public static final int P
- 另请参阅:
- 常量字段值
-
Q
public static final int Q
- 另请参阅:
- 常量字段值
-
R
public static final int R
- 另请参阅:
- 常量字段值
-
STRING_A_LENGTH
public static final int STRING_A_LENGTH
- 另请参阅:
- 常量字段值
-
CLASS_A_NAME
public static final int CLASS_A_NAME
- 另请参阅:
- 常量字段值
-
CLASS_A_SIMPLE_NAME
public static final int CLASS_A_SIMPLE_NAME
- 另请参阅:
- 常量字段值
-
BOOLEAN_A_STRING
public static final int BOOLEAN_A_STRING
- 另请参阅:
- 常量字段值
-
CHAR_A_STRING
public static final int CHAR_A_STRING
- 另请参阅:
- 常量字段值
-
INT_A_STRING
public static final int INT_A_STRING
- 另请参阅:
- 常量字段值
-
LONG_A_STRING
public static final int LONG_A_STRING
- 另请参阅:
- 常量字段值
-
FLOAT_A_STRING
public static final int FLOAT_A_STRING
- 另请参阅:
- 常量字段值
-
DOUBLE_A_STRING
public static final int DOUBLE_A_STRING
- 另请参阅:
- 常量字段值
-
STRING_A_STRING
public static final int STRING_A_STRING
- 另请参阅:
- 常量字段值
-
BOOLEAN_B_STRING
public static final int BOOLEAN_B_STRING
- 另请参阅:
- 常量字段值
-
CHAR_B_STRING
public static final int CHAR_B_STRING
- 另请参阅:
- 常量字段值
-
INT_B_STRING
public static final int INT_B_STRING
- 另请参阅:
- 常量字段值
-
LONG_B_STRING
public static final int LONG_B_STRING
- 另请参阅:
- 常量字段值
-
FLOAT_B_STRING
public static final int FLOAT_B_STRING
- 另请参阅:
- 常量字段值
-
DOUBLE_B_STRING
public static final int DOUBLE_B_STRING
- 另请参阅:
- 常量字段值
-
STRING_B_STRING
public static final int STRING_B_STRING
- 另请参阅:
- 常量字段值
-
-
构造器详细资料
-
InstructionSequenceReplacer
public InstructionSequenceReplacer(Constant[] patternConstants, Instruction[] patternInstructions, Constant[] replacementConstants, Instruction[] replacementInstructions, BranchTargetFinder branchTargetFinder, CodeAttributeEditor codeAttributeEditor)
Creates a new InstructionSequenceReplacer.- 参数:
patternConstants- any constants referenced by the pattern instructions.patternInstructions- the pattern instruction sequence.replacementConstants- any constants referenced by the replacement instructions.replacementInstructions- the replacement instruction sequence.branchTargetFinder- a branch target finder that has been initialized to indicate branch targets in the visited code.codeAttributeEditor- a code editor that can be used for accumulating changes to the code.
-
InstructionSequenceReplacer
public InstructionSequenceReplacer(Constant[] patternConstants, Instruction[] patternInstructions, Constant[] replacementConstants, Instruction[] replacementInstructions, BranchTargetFinder branchTargetFinder, CodeAttributeEditor codeAttributeEditor, InstructionVisitor extraInstructionVisitor)
Creates a new InstructionSequenceReplacer.- 参数:
patternConstants- any constants referenced by the pattern instructions.patternInstructions- the pattern instruction sequence.replacementConstants- any constants referenced by the replacement instructions.replacementInstructions- the replacement instruction sequence.branchTargetFinder- a branch target finder that has been initialized to indicate branch targets in the visited code.codeAttributeEditor- a code editor that can be used for accumulating changes to the code.extraInstructionVisitor- an optional extra visitor for all deleted load instructions.
-
InstructionSequenceReplacer
@Deprecated public InstructionSequenceReplacer(InstructionSequenceMatcher instructionSequenceMatcher, Constant[] patternConstants, Instruction[] patternInstructions, Constant[] replacementConstants, Instruction[] replacementInstructions, BranchTargetFinder branchTargetFinder, CodeAttributeEditor codeAttributeEditor, InstructionVisitor extraInstructionVisitor)
已过时。Creates a new InstructionSequenceReplacer.- 参数:
instructionSequenceMatcher- a suitable instruction sequence matcher.patternConstants- any constants referenced by the pattern instructions.patternInstructions- the pattern instruction sequence.replacementConstants- any constants referenced by the replacement instructions.replacementInstructions- the replacement instruction sequence.branchTargetFinder- a branch target finder that has been initialized to indicate branch targets in the visited code.codeAttributeEditor- a code editor that can be used for accumulating changes to the code.extraInstructionVisitor- an optional extra visitor for all deleted load instructions.
-
InstructionSequenceReplacer
protected InstructionSequenceReplacer(InstructionSequenceMatcher instructionSequenceMatcher, Constant[] replacementConstants, Instruction[] replacementInstructions, BranchTargetFinder branchTargetFinder, CodeAttributeEditor codeAttributeEditor, InstructionVisitor extraInstructionVisitor)
Creates a new InstructionSequenceReplacer.- 参数:
instructionSequenceMatcher- a suitable instruction sequence matcher.replacementConstants- any constants referenced by the replacement instructions.replacementInstructions- the replacement instruction sequence.branchTargetFinder- a branch target finder that has been initialized to indicate branch targets in the visited code.codeAttributeEditor- a code editor that can be used for accumulating changes to the code.extraInstructionVisitor- an optional extra visitor for all deleted load instructions.
-
-
方法详细资料
-
visitAnyInstruction
public void visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction)
从接口复制的说明:InstructionVisitorVisits any Instruction instance. The more specific default implementations of this interface delegate to this method.- 指定者:
visitAnyInstruction在接口中InstructionVisitor
-
matchedArgument
protected int matchedArgument(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, int argument)
Returns the matched argument for the given pattern argument.
-
matchedArgument
protected int matchedArgument(Clazz clazz, int argument)
Returns the matched argument for the given pattern argument.
-
matchedConstantIndex
@Deprecated protected int matchedConstantIndex(ProgramClass programClass, int constantIndex)
已过时。
-
matchedConstantIndex
protected int matchedConstantIndex(ProgramClass programClass, ProgramMethod programMethod, int constantIndex)
Returns the matched or newly created constant index for the given pattern constant index.
-
matchedBranchOffset
protected int matchedBranchOffset(int offset, int branchOffset)Returns the value of the specified matched branch offset.
-
matchedJumpOffsets
protected int[] matchedJumpOffsets(int offset, int[] jumpOffsets)Returns the values of the specified matched jump offsets.
-
getInstructionSequenceMatcher
protected InstructionSequenceMatcher getInstructionSequenceMatcher()
-
wasConstant
protected boolean wasConstant(int argument)
-
matchedConstant
protected Constant matchedConstant(ProgramClass programClass, int argument)
-
matchedArgument
protected int matchedArgument(int argument)
-
label
public static InstructionSequenceReplacer.Label label()
Creates a new label that can be used as a pseudo-instruction to mark a local offset. Its offset can be used as a branch target in replacement instructions (InstructionSequenceReplacer.Label.offset()).
-
catch_
public static InstructionSequenceReplacer.Label catch_(int startOffset, int endOffset, int catchType)
Creates a new catch instance that can be used as a pseudo-instruction to mark the start of an exception handler. Its offset can be used as a branch target in replacement instructions (InstructionSequenceReplacer.Label.offset()).
-
-