public class ExecutingInvocationUnit extends BasicInvocationUnit
This ExecutingInvocationUnit reflectively executes the method calls it visits on a given
ParticularReferenceValue.
After the (reflective) execution of method, it also takes care to replace values on stack/variables if needed. This needs to be done, as the PartialEvaluator treats all entries on stack/variables as immutable, and assumes that every change creates a new object.
Before a method call, the stack/variables can contain multiple references to the same object. If the method call then creates a new Variable (representing an updated object), we need to update all references to this new Variable.
There are some methods which always return a new object when the method is actually executed in the JVM (e.g. StringBuilder.toString). For such method calls, we never update the stack/variables (Blacklist, Case 1)
For certain methods (e.g. the Constructor), we always need to replace the value on stack/variables (Whitelist, Case 3)
In all other cases, we assume the underlying object was changed if the returned value is of the same type as the called upon instance. This is an approximation, which works well for Strings, StringBuffer, StringBuilder (Approximation, Case 3)
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG |
valueFactory| Constructor and Description |
|---|
ExecutingInvocationUnit(ValueFactory valueFactory) |
| Modifier and Type | Method and Description |
|---|---|
Value |
getMethodReturnValue(Clazz clazz,
AnyMethodrefConstant anyMethodrefConstant,
java.lang.String returnType)
Returns the return value of the specified method.
|
boolean |
methodMayHaveSideEffects(Clazz clazz,
AnyMethodrefConstant anyMethodrefConstant,
java.lang.String returnType)
Returns true if the method itself can modify the stack/variables and therefore
needs to be executed even if it returns void.
|
void |
setMethodParameterValue(Clazz clazz,
AnyMethodrefConstant anyMethodrefConstant,
int parameterIndex,
Value value)
Sets the value of the specified method parameter.
|
void |
visitAnyMethodrefConstant(Clazz clazz,
AnyMethodrefConstant anyMethodrefConstant)
Visits any RefConstant instance.
|
getExceptionValue, getFieldClassValue, getFieldValue, getMethodParameterValue, getMethodReturnValue, setFieldClassValue, setFieldValue, setMethodReturnValue, visitLibraryField, visitLibraryMethod, visitProgramField, visitProgramMethodenterExceptionHandler, enterMethod, exitMethod, invokeMember, visitFieldrefConstant, visitInvokeDynamicConstant, visitParameterclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitenterExceptionHandler, enterMethod, exitMethod, invokeMembervisitAnyMember, visitLibraryMember, visitProgramMembervisitAnyConstant, visitAnyRefConstant, visitClassConstant, visitDoubleConstant, visitDynamicConstant, visitFloatConstant, visitIntegerConstant, visitInterfaceMethodrefConstant, visitLongConstant, visitMethodHandleConstant, visitMethodrefConstant, visitMethodTypeConstant, visitModuleConstant, visitNameAndTypeConstant, visitPackageConstant, visitPrimitiveArrayConstant, visitStringConstant, visitUtf8Constantpublic ExecutingInvocationUnit(ValueFactory valueFactory)
public void setMethodParameterValue(Clazz clazz, AnyMethodrefConstant anyMethodrefConstant, int parameterIndex, Value value)
SimplifiedInvocationUnitsetMethodParameterValue in class BasicInvocationUnitpublic boolean methodMayHaveSideEffects(Clazz clazz, AnyMethodrefConstant anyMethodrefConstant, java.lang.String returnType)
SimplifiedInvocationUnitmethodMayHaveSideEffects in class SimplifiedInvocationUnitpublic Value getMethodReturnValue(Clazz clazz, AnyMethodrefConstant anyMethodrefConstant, java.lang.String returnType)
SimplifiedInvocationUnitgetMethodReturnValue in class BasicInvocationUnitpublic void visitAnyMethodrefConstant(Clazz clazz, AnyMethodrefConstant anyMethodrefConstant)
ConstantVisitorvisitAnyMethodrefConstant in interface ConstantVisitorvisitAnyMethodrefConstant in class SimplifiedInvocationUnit