framework.src.org.checkerframework.common.reflection.ReflectionResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of checker Show documentation
Show all versions of checker Show documentation
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.reflection;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.List;
import org.checkerframework.framework.type.AnnotatedTypeFactory;
import org.checkerframework.framework.type.AnnotatedTypeMirror;
import org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedExecutableType;
import org.checkerframework.javacutil.Pair;
import com.sun.source.tree.MethodInvocationTree;
/**
* Interface for reflection resolvers that handle reflective method calls such
* as {@link Method#invoke(Object, Object...)} or
* {@link Constructor#newInstance(Object...)}.
*
* @checker_framework.manual #reflection-resolution Reflection resolution
*
* @author rjust
*
*/
public interface ReflectionResolver {
/**
* Constant for "method name" of constructors
*/
public static final String INIT = "";
/**
* Determines whether the given tree represents a reflective method or
* constructor call.
*
* @return true
iff tree is a reflective method invocation,
* false
otherwise
*/
public boolean isReflectiveMethodInvocation(MethodInvocationTree tree);
/**
* Resolve reflection and return the result of
* factory.methodFromUse
for the actual, resolved method or
* constructor call. If the reflective method cannot be resolved the
* original result (origResult
) is returned.
*
* @param factory
* the currently used AnnotatedTypeFactory
* @param tree
* the reflective invocation tree (m.invoke or c.newInstance)
* @param origResult
* the original result for the unresolved, reflective method call
*/
public Pair> resolveReflectiveCall(
AnnotatedTypeFactory factory, MethodInvocationTree tree,
Pair> origResult);
}