Interface TypeAnnotation


public sealed interface TypeAnnotation
TypeAnnotation is a preview API of the Java platform.
Programs can only use TypeAnnotation when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Models a type_annotation structure (JVMS 4.7.20). This model indicates the annotated type within a declaration or expression and the part of the indicated type that is annotated, in addition to what is available in an Annotation.

This model can reconstruct an annotation on a type or a part of a type, given the location of the type_annotation structure in the class file and the definition of the annotation interface.

Two TypeAnnotation objects should be compared using the equals method.

Since:
22
See Also:
  • Method Details

    • targetInfo

      Returns information describing precisely which type in a declaration or expression is annotated. This models the target_type and target_info items.
      Returns:
      information describing precisely which type in a declaration or expression is annotated
    • targetPath

      Returns which part of the type indicated by targetInfo() is annotated.
      Returns:
      which part of the type indicated by targetInfo() is annotated
    • annotation

      AnnotationPREVIEW annotation()
      Returns the annotation applied to the part indicated by targetPath(). This models the interface of the annotation and the set of element-value pairs, the subset of the type_annotation structure that is identical to the annotation structure.
      Returns:
      the annotation applied to the part indicated by targetPath()
    • of

      Returns a type_annotation structure.
      Parameters:
      targetInfo - which type in a declaration or expression is annotated
      targetPath - which part of the type is annotated
      annotation - the annotation
      Returns:
      a type_annotation structure