Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
The Checker Framework enhances Java's type system to
make it more powerful and useful. This lets software developers
detect and prevent errors in their Java programs.
The Checker Framework includes compiler plug-ins ("checkers")
that find bugs or verify their absence. It also permits you to
write your own compiler plug-ins.
package org.checkerframework.common.value;
import com.sun.source.tree.ExpressionTree;
import com.sun.source.tree.MethodInvocationTree;
import com.sun.source.tree.NewClassTree;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
import org.checkerframework.checker.signature.qual.CanonicalNameOrEmpty;
import org.checkerframework.checker.signature.qual.ClassGetName;
import org.checkerframework.common.basetype.BaseTypeChecker;
import org.checkerframework.javacutil.ElementUtils;
import org.checkerframework.javacutil.TreeUtils;
import org.checkerframework.javacutil.TypesUtils;
import org.plumelib.util.CollectionsPlume;
import org.plumelib.util.StringsPlume;
/**
* Evaluates expressions (such as method calls and field accesses) at compile time, to determine
* whether they have compile-time constant values.
*/
public class ReflectiveEvaluator {
/** The checker that is using this ReflectiveEvaluator. */
private BaseTypeChecker checker;
/**
* Whether to report warnings about problems with evaluation. Controlled by the -AreportEvalWarns
* command-line option.
*/
private boolean reportWarnings;
public ReflectiveEvaluator(
BaseTypeChecker checker, ValueAnnotatedTypeFactory factory, boolean reportWarnings) {
this.checker = checker;
this.reportWarnings = reportWarnings;
}
/**
* Returns all possible values that the method may return, or null if the method could not be
* evaluated.
*
* @param allArgValues a list of list where the first list corresponds to all possible values for
* the first argument. Pass null to indicate that the method has no arguments.
* @param receiverValues a list of possible receiver values. null indicates that the method has no
* receiver.
* @param tree location to report any errors
* @return all possible values that the method may return, or null if the method could not be
* evaluated
*/
public List evaluateMethodCall(
List> allArgValues, List receiverValues, MethodInvocationTree tree) {
Method method = getMethodObject(tree);
if (method == null) {
return null;
}
if (receiverValues == null) {
// Method does not have a receiver
// the first parameter of Method.invoke should be null
receiverValues = Collections.singletonList(null);
}
List