Class BasicAnnotationProvider

java.lang.Object
org.checkerframework.javacutil.BasicAnnotationProvider
All Implemented Interfaces:
AnnotationProvider

public class BasicAnnotationProvider extends Object implements AnnotationProvider
An AnnotationProvider that is independent of any type hierarchy.
  • Constructor Details

    • BasicAnnotationProvider

      public BasicAnnotationProvider()
  • Method Details

    • getDeclAnnotation

      public @Nullable AnnotationMirror getDeclAnnotation(Element elt, Class<? extends Annotation> anno)
      Returns the AnnotationMirror, of the given class, used to annotate the element. Returns null if no such annotation exists.
      Specified by:
      getDeclAnnotation in interface AnnotationProvider
      Parameters:
      elt - the element
      anno - annotation class
      Returns:
      an annotation mirror of class anno on elt, or an equivalent one, or null if none exists on anno
    • getAnnotationMirror

      public @Nullable AnnotationMirror getAnnotationMirror(Tree tree, Class<? extends Annotation> target)
      Return the annotation on tree that is in the hierarchy that contains the qualifier target. Returns null if none exists.

      This implementation always returns null, because it has no access to any type hierarchy.

      Specified by:
      getAnnotationMirror in interface AnnotationProvider
      Parameters:
      tree - the tree of which the annotation is returned
      target - the class of the annotation
      Returns:
      the annotation on tree that has the class target, or null
    • isSideEffectFree

      public boolean isSideEffectFree(ExecutableElement methodElement)
      Returns true if the given method is side-effect-free according to this AnnotationProvider — that is, if a call to the given method does not undo flow-sensitive type refinement.

      Note that this method takes account of this AnnotationProvider's semantics, whereas org.checkerframework.dataflow.util.PurityUtils#isSideEffectFree does not.

      This implementation returns true if the @SideEffectFree annotation is present on the given method.

      Specified by:
      isSideEffectFree in interface AnnotationProvider
      Parameters:
      methodElement - a method
      Returns:
      true if a call to the method does not undo flow-sensitive type refinement
    • isDeterministic

      public boolean isDeterministic(ExecutableElement methodElement)
      Returns true if the given method is deterministic according to this AnnotationProvider — that is, if multiple calls to the given method (with the same arguments) return the same value.

      Note that this method takes account of this AnnotationProvider's semantics, whereas org.checkerframework.dataflow.util.PurityUtils#isDeterministic does not.

      This implementation returns true if the @Deterministic annotation is present on the given method.

      Specified by:
      isDeterministic in interface AnnotationProvider
      Parameters:
      methodElement - a method
      Returns:
      true if multiple calls to the method (with the same arguments) return the same value