Class ReflectiveEvaluator
- java.lang.Object
-
- org.checkerframework.common.value.ReflectiveEvaluator
-
public class ReflectiveEvaluator extends java.lang.Object
Evaluates expressions (such as method calls and field accesses) at compile time, to determine whether they have compile-time constant values.
-
-
Constructor Summary
Constructors Constructor Description ReflectiveEvaluator(BaseTypeChecker checker, ValueAnnotatedTypeFactory factory, boolean reportWarnings)
Create a new ReflectiveEvaluator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable java.util.List<?>
evaluateMethodCall(@Nullable java.util.List<java.util.List<?>> allArgValues, @Nullable java.util.List<?> receiverValues, com.sun.source.tree.MethodInvocationTree tree)
Returns all possible values that the method may return, or null if the method could not be evaluated.@Nullable java.lang.Object
evaluateStaticFieldAccess(@ClassGetName java.lang.String classname, java.lang.String fieldName, com.sun.source.tree.ExpressionTree tree)
Return the value of a static field access.@Nullable java.util.List<?>
evaluteConstructorCall(java.util.List<java.util.List<?>> argValues, com.sun.source.tree.NewClassTree tree, javax.lang.model.type.TypeMirror typeToCreate)
-
-
-
Constructor Detail
-
ReflectiveEvaluator
public ReflectiveEvaluator(BaseTypeChecker checker, ValueAnnotatedTypeFactory factory, boolean reportWarnings)
Create a new ReflectiveEvaluator.- Parameters:
checker
- the BaseTypeCheckerfactory
- the annotated type factoryreportWarnings
- if true, report warnings about problems with evaluation
-
-
Method Detail
-
evaluateMethodCall
public @Nullable java.util.List<?> evaluateMethodCall(@Nullable java.util.List<java.util.List<?>> allArgValues, @Nullable java.util.List<?> receiverValues, com.sun.source.tree.MethodInvocationTree tree)
Returns all possible values that the method may return, or null if the method could not be evaluated.- Parameters:
allArgValues
- a list of lists where the first list corresponds to all possible values for the first argument. Pass null to indicate that the method has no arguments.receiverValues
- a list of possible receiver values. null indicates that the method has no receiver.tree
- location to report any errors- Returns:
- all possible values that the method may return, or null if the method could not be evaluated
-
evaluateStaticFieldAccess
public @Nullable java.lang.Object evaluateStaticFieldAccess(@ClassGetName java.lang.String classname, java.lang.String fieldName, com.sun.source.tree.ExpressionTree tree)
Return the value of a static field access. Return null if accessing the field reflectively fails.- Parameters:
classname
- the class containing the fieldfieldName
- the name of the fieldtree
- the static field access in the program. It is a MemberSelectTree or an IdentifierTree and is used for diagnostics.- Returns:
- the value of the static field access, or null if it cannot be determined
-
evaluteConstructorCall
public @Nullable java.util.List<?> evaluteConstructorCall(java.util.List<java.util.List<?>> argValues, com.sun.source.tree.NewClassTree tree, javax.lang.model.type.TypeMirror typeToCreate)
-
-