Package proguard.evaluation.executor
Class ReflectionExecutor
java.lang.Object
proguard.evaluation.executor.ReflectionExecutor
- All Implemented Interfaces:
Executor
- Direct Known Subclasses:
StringReflectionExecutor
This
Executor provides an implementation for Executor.getMethodResult(proguard.evaluation.executor.MethodExecutionInfo, proguard.evaluation.ValueCalculator) which tries
to resolve the method at runtime and execute it using Java's reflection API java.lang.reflect.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface proguard.evaluation.executor.Executor
Executor.Builder<T extends Executor> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ExecutorInstanceHandlerProvides a default instance handler used by the executor in case the reflective execution fails.protected abstract Optional<ReflectionExecutor.InstanceCopyResult>getInstanceOrCopyIfMutable(ReferenceValue instanceValue) Get an object which will act as the calling instance.getMethodResult(MethodExecutionInfo methodExecutionInfo, ValueCalculator valueCalculator) Calculate the result of a given method.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface proguard.evaluation.executor.Executor
getSupportedMethodSignatures
-
Constructor Details
-
ReflectionExecutor
public ReflectionExecutor()
-
-
Method Details
-
getMethodResult
public MethodResult getMethodResult(MethodExecutionInfo methodExecutionInfo, ValueCalculator valueCalculator) Description copied from interface:ExecutorCalculate the result of a given method. This is the return value for a non-constructor method (null if it returnsvoid ) and the instantiated object for a constructor.- Specified by:
getMethodResultin interfaceExecutor- Parameters:
methodExecutionInfo- Information about the called method.valueCalculator- a function mapping the result of a method invocation (can be an Object with the result if the executor calculates a real value or aModel) to the appropriateValueused by the analysis. Should also be used to create values of unknown value since the executor might be able to provide additional information on them even if the value itself is not known (e.g., on the identifier of the returned value).- Returns:
- The result of the method call, including information on the returned value or values or
arguments on which side effects happened during the method execution. If the executor is
not able to provide any additional information for any reason the returned value should be
MethodResult.invalidResult(), so that the caller can know that execution failed and just provide its best approximation of the result.
-
getInstanceOrCopyIfMutable
protected abstract Optional<ReflectionExecutor.InstanceCopyResult> getInstanceOrCopyIfMutable(ReferenceValue instanceValue) Get an object which will act as the calling instance. If we know that executing the method does not modify the instance this can just be the same value. Otherwise, a copy should be returned in order to not change the reference whose state may be of interest at the end of an analysis.- Parameters:
instanceValue- TheReferenceValueof the instance.- Returns:
- The new calling instance.
-
getDefaultInstanceHandler
Provides a default instance handler used by the executor in case the reflective execution fails.The handler carries information on whether a method returns the same object as its instance.
- Returns:
- the default instance handler.
-