public class ReflectiveModelExecutor extends java.lang.Object implements Executor
Executor with support for ReflectiveModels.
Checks the parameters sanity so that the models can work assuming they get clean data and
matches the target ReflectiveModel and executes the method on it via the reflection
supported by ModelHelper.
| Modifier and Type | Class and Description |
|---|---|
static class |
ReflectiveModelExecutor.Builder
Builder for
ReflectiveModelExecutor. |
static class |
ReflectiveModelExecutor.SupportedModelInfo<T extends ReflectiveModel<T>>
Information provided by an executor to communicate which classes it supports.
|
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Set<ReflectiveModelExecutor.SupportedModelInfo<? extends ReflectiveModel<?>>> |
supportedModels |
protected java.util.Set<MethodSignature> |
supportedSignatures |
protected java.util.Map<MethodSignature,java.lang.Class<? extends ReflectiveModel<?>>> |
supportedSignatureToModel |
| Modifier | Constructor and Description |
|---|---|
protected |
ReflectiveModelExecutor(java.util.Set<ReflectiveModelExecutor.SupportedModelInfo<?>> supportedModels,
HierarchyProvider hierarchy) |
| Modifier and Type | Method and Description |
|---|---|
static <T extends ReflectiveModel<T>> |
generateMethodSignaturesForModel(ReflectiveModelExecutor.SupportedModelInfo<T> modelInfo,
HierarchyProvider hierarchy)
Computes the methods the executor needs to support for the specified classes.
|
MethodResult |
getMethodResult(MethodExecutionInfo methodExecutionInfo,
ValueCalculator valueCalculator)
Calculate the result of a given method.
|
java.util.Set<MethodSignature> |
getSupportedMethodSignatures()
Get a list of method signatures that indicate which methods are supported by this executor.
|
protected final java.util.Set<ReflectiveModelExecutor.SupportedModelInfo<? extends ReflectiveModel<?>>> supportedModels
protected final java.util.Set<MethodSignature> supportedSignatures
protected final java.util.Map<MethodSignature,java.lang.Class<? extends ReflectiveModel<?>>> supportedSignatureToModel
protected ReflectiveModelExecutor(java.util.Set<ReflectiveModelExecutor.SupportedModelInfo<?>> supportedModels, HierarchyProvider hierarchy)
public MethodResult getMethodResult(MethodExecutionInfo methodExecutionInfo, ValueCalculator valueCalculator)
ExecutorgetMethodResult in interface ExecutormethodExecutionInfo - 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 a Model) to the
appropriate Value used 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).MethodResult.invalidResult(), so that the caller can know that execution failed and
just provide its best approximation of the result.public java.util.Set<MethodSignature> getSupportedMethodSignatures()
ExecutorThe returned methods should be exactly the ones that the executor is expected to be able to handle. The invocation unit does not make any additional assumption on the executors available to execute a method and will match them iff the signature of the target method matches exactly.
Only full method signatures should be returned, the invocation unit does not support wildcards.
getSupportedMethodSignatures in interface Executorpublic static <T extends ReflectiveModel<T>> java.util.Set<MethodSignature> generateMethodSignaturesForModel(ReflectiveModelExecutor.SupportedModelInfo<T> modelInfo, HierarchyProvider hierarchy)
ReflectiveModel and additionally a
signature for each class extending the class if inheritance has to be supported.T - the model modeling the clazz.modelInfo - information on which classes the executor wants to support (e.g., only the
class modeled by a model or also everything implementing it, etc.)hierarchy - the class hierarchy.