Package proguard.classfile.util
Class BranchTargetFinder
- java.lang.Object
-
- proguard.classfile.util.BranchTargetFinder
-
- All Implemented Interfaces:
AttributeVisitor
,ExceptionInfoVisitor
,ConstantVisitor
,InstructionVisitor
public class BranchTargetFinder extends java.lang.Object implements AttributeVisitor, InstructionVisitor, ExceptionInfoVisitor, ConstantVisitor
ThisAttributeVisitor
finds all instruction offsets, branch targets, and exception targets in theCodeAttribute
instances that it visits.
-
-
Field Summary
Fields Modifier and Type Field Description static int
NO_SUBROUTINE
static int
UNKNOWN
-
Constructor Summary
Constructors Constructor Description BranchTargetFinder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsSubroutines()
Returns whether the method contains subroutines, in the CodeAttribute that was visited most recently.boolean
isAfterBranch(int offset)
Returns whether the instruction at the given offset comes right after a definite branch instruction in the CodeAttribute that was visited most recently.boolean
isBranchOrigin(int offset)
Returns whether the instruction at the given offset is the origin of a branch instruction in the CodeAttribute that was visited most recently.boolean
isBranchTarget(int offset)
Returns whether the instruction at the given offset is the target of a branch instruction in the CodeAttribute that was visited most recently.boolean
isCreation(int offset)
Returns whether the instruction at the given offset creates a new, uninitialized object instance, in the CodeAttribute that was visited most recently.boolean
isExceptionEnd(int offset)
Returns whether the instruction at the given offset is the end of an exception try block in the CodeAttribute that was visited most recently.boolean
isExceptionHandler(int offset)
Returns whether the instruction at the given offset is the start of an exception handler in the CodeAttribute that was visited most recently.boolean
isExceptionStart(int offset)
Returns whether the instruction at the given offset is the start of an exception try block in the CodeAttribute that was visited most recently.boolean
isInitializer(int offset)
Returns whether the instruction at the given offset is the special invocation of an instance initializer, in the CodeAttribute that was visited most recently.boolean
isInstruction(int offset)
Returns whether there is an instruction at the given offset in the CodeAttribute that was visited most recently.boolean
isSubroutine(int offset)
Returns whether the instruction at the given offset is part of a subroutine in the CodeAttribute that was visited most recently.boolean
isSubroutineInvocation(int offset)
Returns whether the instruction at the given offset is a subroutine invocation in the CodeAttribute that was visited most recently.boolean
isSubroutineReturning(int offset)
Returns whether the subroutine at the given offset is ever returning by means of a regular 'ret' instruction.boolean
isSubroutineStart(int offset)
Returns whether the instruction at the given offset is the start of a subroutine in the CodeAttribute that was visited most recently.boolean
isTarget(int offset)
Returns whether the instruction at the given offset is the target of any kind in the CodeAttribute that was visited most recently.int
subroutineEnd(int offset)
Returns the offset after the subroutine at the given offset, in the CodeAttribute that was visited most recently.int
subroutineStart(int offset)
Returns the start offset of the subroutine at the given offset, in the CodeAttribute that was visited most recently.void
visitAnyAttribute(Clazz clazz, Attribute attribute)
Visits any Attribute instance.void
visitAnyConstant(Clazz clazz, Constant constant)
Visits any Constant instance.void
visitAnySwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SwitchInstruction switchInstruction)
Visits any SwitchInstruction instance.void
visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
void
visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
void
visitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction)
void
visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo)
void
visitMethodrefConstant(Clazz clazz, MethodrefConstant methodrefConstant)
void
visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction)
void
visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface proguard.classfile.attribute.visitor.AttributeVisitor
visitAnnotationDefaultAttribute, visitAnyAnnotationsAttribute, visitAnyParameterAnnotationsAttribute, visitAnyTypeAnnotationsAttribute, visitBootstrapMethodsAttribute, visitConstantValueAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitEnclosingMethodAttribute, visitExceptionsAttribute, visitInnerClassesAttribute, visitLineNumberTableAttribute, visitLocalVariableTableAttribute, visitLocalVariableTypeTableAttribute, visitMethodParametersAttribute, visitModuleAttribute, visitModuleMainClassAttribute, visitModulePackagesAttribute, visitNestHostAttribute, visitNestMembersAttribute, visitPermittedSubclassesAttribute, visitRecordAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleParameterAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleParameterAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSourceDebugExtensionAttribute, visitSourceDirAttribute, visitSourceFileAttribute, visitStackMapAttribute, visitStackMapTableAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitUnknownAttribute
-
Methods inherited from interface proguard.classfile.constant.visitor.ConstantVisitor
visitAnyMethodrefConstant, visitAnyRefConstant, visitClassConstant, visitDoubleConstant, visitDynamicConstant, visitFieldrefConstant, visitFloatConstant, visitIntegerConstant, visitInterfaceMethodrefConstant, visitInvokeDynamicConstant, visitLongConstant, visitMethodHandleConstant, visitMethodTypeConstant, visitModuleConstant, visitNameAndTypeConstant, visitPackageConstant, visitPrimitiveArrayConstant, visitStringConstant, visitUtf8Constant
-
Methods inherited from interface proguard.classfile.instruction.visitor.InstructionVisitor
visitAnyInstruction, visitLookUpSwitchInstruction, visitTableSwitchInstruction
-
-
-
-
Field Detail
-
UNKNOWN
public static final int UNKNOWN
- See Also:
- Constant Field Values
-
NO_SUBROUTINE
public static final int NO_SUBROUTINE
- See Also:
- Constant Field Values
-
-
Method Detail
-
isInstruction
public boolean isInstruction(int offset)
Returns whether there is an instruction at the given offset in the CodeAttribute that was visited most recently.
-
isCreation
public boolean isCreation(int offset)
Returns whether the instruction at the given offset creates a new, uninitialized object instance, in the CodeAttribute that was visited most recently.
-
isInitializer
public boolean isInitializer(int offset)
Returns whether the instruction at the given offset is the special invocation of an instance initializer, in the CodeAttribute that was visited most recently.
-
isTarget
public boolean isTarget(int offset)
Returns whether the instruction at the given offset is the target of any kind in the CodeAttribute that was visited most recently.
-
isBranchOrigin
public boolean isBranchOrigin(int offset)
Returns whether the instruction at the given offset is the origin of a branch instruction in the CodeAttribute that was visited most recently.
-
isBranchTarget
public boolean isBranchTarget(int offset)
Returns whether the instruction at the given offset is the target of a branch instruction in the CodeAttribute that was visited most recently.
-
isAfterBranch
public boolean isAfterBranch(int offset)
Returns whether the instruction at the given offset comes right after a definite branch instruction in the CodeAttribute that was visited most recently.
-
isExceptionStart
public boolean isExceptionStart(int offset)
Returns whether the instruction at the given offset is the start of an exception try block in the CodeAttribute that was visited most recently.
-
isExceptionEnd
public boolean isExceptionEnd(int offset)
Returns whether the instruction at the given offset is the end of an exception try block in the CodeAttribute that was visited most recently.
-
isExceptionHandler
public boolean isExceptionHandler(int offset)
Returns whether the instruction at the given offset is the start of an exception handler in the CodeAttribute that was visited most recently.
-
isSubroutineInvocation
public boolean isSubroutineInvocation(int offset)
Returns whether the instruction at the given offset is a subroutine invocation in the CodeAttribute that was visited most recently.
-
isSubroutineStart
public boolean isSubroutineStart(int offset)
Returns whether the instruction at the given offset is the start of a subroutine in the CodeAttribute that was visited most recently.
-
isSubroutine
public boolean isSubroutine(int offset)
Returns whether the instruction at the given offset is part of a subroutine in the CodeAttribute that was visited most recently.
-
isSubroutineReturning
public boolean isSubroutineReturning(int offset)
Returns whether the subroutine at the given offset is ever returning by means of a regular 'ret' instruction.
-
subroutineStart
public int subroutineStart(int offset)
Returns the start offset of the subroutine at the given offset, in the CodeAttribute that was visited most recently.
-
subroutineEnd
public int subroutineEnd(int offset)
Returns the offset after the subroutine at the given offset, in the CodeAttribute that was visited most recently.
-
containsSubroutines
public boolean containsSubroutines()
Returns whether the method contains subroutines, in the CodeAttribute that was visited most recently.
-
visitAnyAttribute
public void visitAnyAttribute(Clazz clazz, Attribute attribute)
Description copied from interface:AttributeVisitor
Visits any Attribute instance. The more specific default implementations of this interface delegate to this method.- Specified by:
visitAnyAttribute
in interfaceAttributeVisitor
-
visitCodeAttribute
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
- Specified by:
visitCodeAttribute
in interfaceAttributeVisitor
-
visitSimpleInstruction
public void visitSimpleInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SimpleInstruction simpleInstruction)
- Specified by:
visitSimpleInstruction
in interfaceInstructionVisitor
-
visitConstantInstruction
public void visitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction)
- Specified by:
visitConstantInstruction
in interfaceInstructionVisitor
-
visitVariableInstruction
public void visitVariableInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, VariableInstruction variableInstruction)
- Specified by:
visitVariableInstruction
in interfaceInstructionVisitor
-
visitBranchInstruction
public void visitBranchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, BranchInstruction branchInstruction)
- Specified by:
visitBranchInstruction
in interfaceInstructionVisitor
-
visitAnySwitchInstruction
public void visitAnySwitchInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, SwitchInstruction switchInstruction)
Description copied from interface:InstructionVisitor
Visits any SwitchInstruction instance. The more specific default implementations of this interface delegate to this method.- Specified by:
visitAnySwitchInstruction
in interfaceInstructionVisitor
-
visitAnyConstant
public void visitAnyConstant(Clazz clazz, Constant constant)
Description copied from interface:ConstantVisitor
Visits any Constant instance. The more specific default implementations of this interface delegate to this method.- Specified by:
visitAnyConstant
in interfaceConstantVisitor
-
visitMethodrefConstant
public void visitMethodrefConstant(Clazz clazz, MethodrefConstant methodrefConstant)
- Specified by:
visitMethodrefConstant
in interfaceConstantVisitor
-
visitExceptionInfo
public void visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo)
- Specified by:
visitExceptionInfo
in interfaceExceptionInfoVisitor
-
-