Package proguard.evaluation.executor
Class ReflectionExecutor
- java.lang.Object
-
- proguard.evaluation.executor.ReflectionExecutor
-
- All Implemented Interfaces:
Executor
- Direct Known Subclasses:
StringReflectionExecutor
public abstract class ReflectionExecutor extends java.lang.Object implements Executor
ThisExecutorprovides an implementation forExecutor.getMethodResult(proguard.evaluation.executor.MethodExecutionInfo, proguard.evaluation.ValueCalculator)which tries to resolve the method at runtime and execute it using Java's reflection APIjava.lang.reflect.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReflectionExecutor.InstanceCopyResult-
Nested classes/interfaces inherited from interface proguard.evaluation.executor.Executor
Executor.Builder<T extends Executor>
-
-
Constructor Summary
Constructors Constructor Description ReflectionExecutor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ExecutorInstanceHandlergetDefaultInstanceHandler()Provides a default instance handler used by the executor in case the reflective execution fails.protected abstract java.util.Optional<ReflectionExecutor.InstanceCopyResult>getInstanceOrCopyIfMutable(ReferenceValue instanceValue)Get an object which will act as the calling instance.MethodResultgetMethodResult(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, wait
-
Methods inherited from interface proguard.evaluation.executor.Executor
getSupportedMethodSignatures
-
-
-
-
Method Detail
-
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 java.util.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
protected abstract ExecutorInstanceHandler 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.
-
-