Package Summary Overview Summary

Module java.base
Package java.lang.classfilePREVIEW

# Interface TypeAnnotation

All Superinterfaces:
  `AnnotationPREVIEW`, `ClassFileElementPREVIEW`, `WritableElementPREVIEW<AnnotationPREVIEW>`

public sealed interface TypeAnnotation extends AnnotationPREVIEW
`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 an annotation on a type use, as defined in 4.7.19 and 4.7.20.

Since:
  22
See Also:
  - `RuntimeVisibleTypeAnnotationsAttribute`PREVIEW
  - `RuntimeInvisibleTypeAnnotationsAttribute`PREVIEW

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static interface`
  `TypeAnnotation.CatchTargetPREVIEW`
  Preview.
  Indicates that an annotation appears on the i'th type in an exception parameter declaration.
  `static interface`
  `TypeAnnotation.EmptyTargetPREVIEW`
  Preview.
  Indicates that an annotation appears on either the type in a field declaration, the return type of a method, the type of a newly constructed object, or the receiver type of a method or constructor.
  `static interface`
  `TypeAnnotation.FormalParameterTargetPREVIEW`
  Preview.
  Indicates that an annotation appears on the type in a formal parameter declaration of a method, constructor, or lambda expression.
  `static interface`
  `TypeAnnotation.LocalVarTargetPREVIEW`
  Preview.
  Indicates that an annotation appears on the type in a local variable declaration, including a variable declared as a resource in a try-with-resources statement.
  `static interface`
  `TypeAnnotation.LocalVarTargetInfoPREVIEW`
  Preview.
  Indicates a range of code array offsets within which a local variable has a value, and the index into the local variable array of the current frame at which that local variable can be found.
  `static interface`
  `TypeAnnotation.OffsetTargetPREVIEW`
  Preview.
  Indicates that an annotation appears on either the type in an instanceof expression or a new expression, or the type before the :: in a method reference expression.
  `static interface`
  `TypeAnnotation.SupertypeTargetPREVIEW`
  Preview.
  Indicates that an annotation appears on a type in the extends or implements clause of a class or interface declaration.
  `static interface`
  `TypeAnnotation.TargetInfoPREVIEW`
  Preview.
  Specifies which type in a declaration or expression is being annotated.
  `static enum`
  `TypeAnnotation.TargetTypePREVIEW`
  Preview.
  The kind of target on which the annotation appears, as defined in 4.7.20.1.
  `static interface`
  `TypeAnnotation.ThrowsTargetPREVIEW`
  Preview.
  Indicates that an annotation appears on the i'th type in the throws clause of a method or constructor declaration.
  `static interface`
  `TypeAnnotation.TypeArgumentTargetPREVIEW`
  Preview.
  Indicates that an annotation appears either on the i'th type in a cast expression, or on the i'th type argument in the explicit type argument list for any of the following: a new expression, an explicit constructor invocation statement, a method invocation expression, or a method reference expression.
  `static interface`
  `TypeAnnotation.TypeParameterBoundTargetPREVIEW`
  Preview.
  Indicates that an annotation appears on the i'th bound of the j'th type parameter declaration of a generic class, interface, method, or constructor.
  `static interface`
  `TypeAnnotation.TypeParameterTargetPREVIEW`
  Preview.
  Indicates that an annotation appears on the declaration of the i'th type parameter of a generic class, generic interface, generic method, or generic constructor.
  `static interface`
  `TypeAnnotation.TypePathComponentPREVIEW`
  Preview.
  JVMS: Type_path structure identifies which part of the type is annotated, as defined in 4.7.20.2

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static TypeAnnotationPREVIEW`
  `of (TypeAnnotation.TargetInfoPREVIEW targetInfo, List<TypeAnnotation.TypePathComponentPREVIEW> targetPath, Utf8EntryPREVIEW annotationClassUtf8Entry, AnnotationElementPREVIEW... annotationElements)`
  Returns a type annotation.
  `static TypeAnnotationPREVIEW`
  `of (TypeAnnotation.TargetInfoPREVIEW targetInfo, List<TypeAnnotation.TypePathComponentPREVIEW> targetPath, Utf8EntryPREVIEW annotationClassUtf8Entry, List<AnnotationElementPREVIEW> annotationElements)`
  Returns a type annotation.
  `static TypeAnnotationPREVIEW`
  `of (TypeAnnotation.TargetInfoPREVIEW targetInfo, List<TypeAnnotation.TypePathComponentPREVIEW> targetPath, ClassDesc annotationClass, AnnotationElementPREVIEW... annotationElements)`
  Returns a type annotation.
  `static TypeAnnotationPREVIEW`
  `of (TypeAnnotation.TargetInfoPREVIEW targetInfo, List<TypeAnnotation.TypePathComponentPREVIEW> targetPath, ClassDesc annotationClass, List<AnnotationElementPREVIEW> annotationElements)`
  Returns a type annotation.
  `TypeAnnotation.TargetInfoPREVIEW`
  `targetInfo()`
  Returns information describing precisely which type in a declaration or expression is annotated.
  `List <TypeAnnotation.TypePathComponentPREVIEW>`
  `targetPath()`
  Returns which part of the type indicated by `targetInfo()` is annotated.

  ### Methods declared in interface java.lang.classfile.AnnotationPREVIEW

  `className, classSymbol, elements`

  ### Methods declared in interface java.lang.classfile.WritableElementPREVIEW

  `writeTo`

- ## Method Details

  - ### targetInfo

    TypeAnnotation.TargetInfoPREVIEW targetInfo()
    Returns information describing precisely which type in a declaration or expression is annotated.
    Returns:
      information describing precisely which type in a declaration or expression is annotated

  - ### targetPath

    List<TypeAnnotation.TypePathComponentPREVIEW> targetPath()
    Returns which part of the type indicated by `targetInfo()` is annotated.
    Returns:
      which part of the type indicated by `targetInfo()` is annotated

  - ### of

    static TypeAnnotationPREVIEW of (TypeAnnotation.TargetInfoPREVIEW targetInfo, List<TypeAnnotation.TypePathComponentPREVIEW> targetPath, Utf8EntryPREVIEW annotationClassUtf8Entry, List<AnnotationElementPREVIEW> annotationElements)
    Returns a type annotation.
    Parameters:
      `targetInfo` - which type in a declaration or expression is annotated
      `targetPath` - which part of the type is annotated
      `annotationClassUtf8Entry` - the annotation class
      `annotationElements` - the annotation elements
    Returns:
      a type annotation

  - ### of

    static TypeAnnotationPREVIEW of (TypeAnnotation.TargetInfoPREVIEW targetInfo, List<TypeAnnotation.TypePathComponentPREVIEW> targetPath, ClassDesc annotationClass, AnnotationElementPREVIEW... annotationElements)
    Returns a type annotation.
    Parameters:
      `targetInfo` - which type in a declaration or expression is annotated
      `targetPath` - which part of the type is annotated
      `annotationClass` - the annotation class
      `annotationElements` - the annotation elements
    Returns:
      a type annotation

  - ### of

    static TypeAnnotationPREVIEW of (TypeAnnotation.TargetInfoPREVIEW targetInfo, List<TypeAnnotation.TypePathComponentPREVIEW> targetPath, ClassDesc annotationClass, List<AnnotationElementPREVIEW> annotationElements)
    Returns a type annotation.
    Parameters:
      `targetInfo` - which type in a declaration or expression is annotated
      `targetPath` - which part of the type is annotated
      `annotationClass` - the annotation class
      `annotationElements` - the annotation elements
    Returns:
      a type annotation

  - ### of

    static TypeAnnotationPREVIEW of (TypeAnnotation.TargetInfoPREVIEW targetInfo, List<TypeAnnotation.TypePathComponentPREVIEW> targetPath, Utf8EntryPREVIEW annotationClassUtf8Entry, AnnotationElementPREVIEW... annotationElements)
    Returns a type annotation.
    Parameters:
      `targetInfo` - which type in a declaration or expression is annotated
      `targetPath` - which part of the type is annotated
      `annotationClassUtf8Entry` - the annotation class
      `annotationElements` - the annotation elements
    Returns:
      a type annotation