public class PartialEvaluator extends java.lang.Object implements AttributeVisitor, ExceptionInfoVisitor
AttributeVisitor
performs partial evaluation on the code attributes that it visits.Modifier and Type | Class and Description |
---|---|
static class |
PartialEvaluator.Builder |
static class |
PartialEvaluator.InstructionBlock
This class represents an instruction block that has to be executed, starting with a given state
at a given instruction offset.
|
Modifier and Type | Field and Description |
---|---|
static int |
AT_CATCH_ENTRY |
static int |
AT_METHOD_ENTRY |
static boolean |
ENABLE_NEW_EXCEPTIONS
Enables new exceptions to be thrown during evaluation.
|
static int |
NONE |
Constructor and Description |
---|
PartialEvaluator()
Creates a simple PartialEvaluator.
|
PartialEvaluator(ValueFactory valueFactory)
Creates a new PartialEvaluator.
|
PartialEvaluator(ValueFactory valueFactory,
InvocationUnit invocationUnit,
boolean evaluateAllCode)
Creates a new PartialEvaluator.
|
PartialEvaluator(ValueFactory valueFactory,
InvocationUnit invocationUnit,
boolean evaluateAllCode,
InstructionVisitor extraInstructionVisitor)
Creates a new PartialEvaluator.
|
Modifier and Type | Method and Description |
---|---|
InstructionOffsetValue |
branchOrigins(int instructionOffset)
Returns the instruction offsets that branch to the given instruction offset.
|
InstructionOffsetValue |
branchTargets(int instructionOffset)
Returns the instruction offsets to which the given instruction offset branches.
|
TracedStack |
getStackAfter(int instructionOffset)
Returns the stack after execution of the instruction at the given offset.
|
TracedStack |
getStackBefore(int instructionOffset)
Returns the stack before execution of the instruction at the given offset.
|
TracedVariables |
getVariablesAfter(int instructionOffset)
Returns the variables after execution of the instruction at the given offset.
|
TracedVariables |
getVariablesBefore(int instructionOffset)
Returns the variables before execution of the instruction at the given offset.
|
boolean |
isBranchOrExceptionTarget(int instructionOffset)
Returns whether the instruction at the given offset is the target of a branch instruction or an
exception.
|
boolean |
isBranchOrigin(int instructionOffset)
Returns whether the instruction at the given offset is the origin of a branch instruction.
|
boolean |
isBranchTarget(int instructionOffset)
Returns whether the instruction at the given offset is the target of a branch instruction.
|
boolean |
isCreation(int offset)
Returns whether the instruction at the given offset creates a new, uninitialized instance.
|
boolean |
isExceptionHandler(int instructionOffset)
Returns whether the instruction at the given offset is the start of an exception handler.
|
boolean |
isInitializer(int offset)
Returns whether the instruction at the given offset is the special invocation of an instance
initializer.
|
boolean |
isInstruction(int instructionOffset)
Returns whether there is an instruction at the given offset.
|
boolean |
isSubroutine(int instructionOffset)
Returns whether the instruction at the given offset is part of a subroutine.
|
boolean |
isSubroutineInvocation(int instructionOffset)
Returns whether the instruction at the given offset is a subroutine invocation.
|
boolean |
isSubroutineReturning(int instructionOffset)
Returns whether the subroutine at the given offset is ever returning by means of a regular
'ret' instruction.
|
boolean |
isSubroutineStart(int instructionOffset)
Returns whether the instruction at the given offset is the start of a subroutine.
|
boolean |
isTarget(int instructionOffset)
Returns whether the instruction at the given offset is the target of any kind.
|
boolean |
isTraced(int instructionOffset)
Returns whether the instruction at the given offset has ever been executed during the partial
evaluation.
|
boolean |
isTraced(int startOffset,
int endOffset)
Returns whether a block of instructions is ever used.
|
PartialEvaluator |
stopAnalysisAfterNEvaluations(int stopAnalysisAfterNEvaluations)
It the analysis visits an instruction this many times (this can happen e.g.
|
int |
subroutineEnd(int instructionOffset)
Returns the offset after the subroutine that starts at the given offset.
|
InstructionVisitor |
tracedInstructionFilter(boolean traced,
InstructionVisitor instructionVisitor)
Returns a filtering version of the given instruction visitor that only visits traced or
untraced instructions.
|
InstructionVisitor |
tracedInstructionFilter(InstructionVisitor instructionVisitor)
Returns a filtering version of the given instruction visitor that only visits traced
instructions.
|
void |
visitAnyAttribute(Clazz clazz,
Attribute attribute)
Visits any Attribute instance.
|
void |
visitCodeAttribute(Clazz clazz,
Method method,
CodeAttribute codeAttribute) |
void |
visitCodeAttribute0(Clazz clazz,
Method method,
CodeAttribute codeAttribute) |
void |
visitExceptionInfo(Clazz clazz,
Method method,
CodeAttribute codeAttribute,
ExceptionInfo exceptionInfo) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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
public static boolean ENABLE_NEW_EXCEPTIONS
public static final int NONE
public static final int AT_METHOD_ENTRY
public static final int AT_CATCH_ENTRY
public PartialEvaluator()
public PartialEvaluator(ValueFactory valueFactory)
valueFactory
- the value factory that will create all values during evaluation.public PartialEvaluator(ValueFactory valueFactory, InvocationUnit invocationUnit, boolean evaluateAllCode)
valueFactory
- the value factory that will create all values during the evaluation.invocationUnit
- the invocation unit that will handle all communication with other fields
and methods.evaluateAllCode
- a flag that specifies whether all casts, branch targets, and exception
handlers should be evaluated, even if they are unnecessary or unreachable.public PartialEvaluator(ValueFactory valueFactory, InvocationUnit invocationUnit, boolean evaluateAllCode, InstructionVisitor extraInstructionVisitor)
valueFactory
- the value factory that will create all values during the evaluation.invocationUnit
- the invocation unit that will handle all communication with other fields
and methods.evaluateAllCode
- a flag that specifies whether all branch targets and exception handlers
should be evaluated, even if they are unreachable.extraInstructionVisitor
- an optional extra visitor for all instructions right before they
are executed.public void visitAnyAttribute(Clazz clazz, Attribute attribute)
AttributeVisitor
visitAnyAttribute
in interface AttributeVisitor
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
visitCodeAttribute
in interface AttributeVisitor
public void visitCodeAttribute0(Clazz clazz, Method method, CodeAttribute codeAttribute)
public boolean isTraced(int startOffset, int endOffset)
public boolean isTraced(int instructionOffset)
public boolean isInstruction(int instructionOffset)
public boolean isTarget(int instructionOffset)
public boolean isBranchOrigin(int instructionOffset)
public boolean isBranchTarget(int instructionOffset)
public boolean isBranchOrExceptionTarget(int instructionOffset)
public boolean isExceptionHandler(int instructionOffset)
public boolean isSubroutineStart(int instructionOffset)
public boolean isSubroutineInvocation(int instructionOffset)
public boolean isSubroutine(int instructionOffset)
public boolean isSubroutineReturning(int instructionOffset)
public int subroutineEnd(int instructionOffset)
public boolean isCreation(int offset)
public boolean isInitializer(int offset)
public TracedVariables getVariablesBefore(int instructionOffset)
public TracedVariables getVariablesAfter(int instructionOffset)
public TracedStack getStackBefore(int instructionOffset)
public TracedStack getStackAfter(int instructionOffset)
public InstructionOffsetValue branchOrigins(int instructionOffset)
public InstructionOffsetValue branchTargets(int instructionOffset)
public InstructionVisitor tracedInstructionFilter(InstructionVisitor instructionVisitor)
public InstructionVisitor tracedInstructionFilter(boolean traced, InstructionVisitor instructionVisitor)
public void visitExceptionInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, ExceptionInfo exceptionInfo)
visitExceptionInfo
in interface ExceptionInfoVisitor
public PartialEvaluator stopAnalysisAfterNEvaluations(int stopAnalysisAfterNEvaluations)