Module java.base
Package java.lang.classfilePREVIEW

# Interface TypeAnnotation.TargetInfo

All Known Subinterfaces:
  `TypeAnnotation.CatchTargetPREVIEW`, `TypeAnnotation.EmptyTargetPREVIEW`, `TypeAnnotation.FormalParameterTargetPREVIEW`, `TypeAnnotation.LocalVarTargetPREVIEW`, `TypeAnnotation.OffsetTargetPREVIEW`, `TypeAnnotation.SupertypeTargetPREVIEW`, `TypeAnnotation.ThrowsTargetPREVIEW`, `TypeAnnotation.TypeArgumentTargetPREVIEW`, `TypeAnnotation.TypeParameterBoundTargetPREVIEW`, `TypeAnnotation.TypeParameterTargetPREVIEW`

Enclosing interface:
  `TypeAnnotationPREVIEW`

public static sealed interface TypeAnnotation.TargetInfo permits TypeAnnotation.TypeParameterTargetPREVIEW, TypeAnnotation.SupertypeTargetPREVIEW, TypeAnnotation.TypeParameterBoundTargetPREVIEW, TypeAnnotation.EmptyTargetPREVIEW, TypeAnnotation.FormalParameterTargetPREVIEW, TypeAnnotation.ThrowsTargetPREVIEW, TypeAnnotation.LocalVarTargetPREVIEW, TypeAnnotation.CatchTargetPREVIEW, TypeAnnotation.OffsetTargetPREVIEW, TypeAnnotation.TypeArgumentTargetPREVIEW
`TargetInfo` is a preview API of the Java platform.
Programs can only use `TargetInfo` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Specifies which type in a declaration or expression is being annotated.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static TypeAnnotation.EmptyTargetPREVIEW`
  `of(TypeAnnotation.TargetTypePREVIEW targetType)`
  Returns a target for annotations.
  `static TypeAnnotation.TypeArgumentTargetPREVIEW`
  `ofCastExpr(LabelPREVIEW target, int typeArgumentIndex)`
  Returns a target for annotations on the i'th type in a cast expression.
  `static TypeAnnotation.SupertypeTargetPREVIEW`
  `ofClassExtends(int supertypeIndex)`
  Returns a target for annotations on the type of an "extends" or "implements" clause.
  `static TypeAnnotation.TypeParameterTargetPREVIEW`
  `ofClassTypeParameter(int typeParameterIndex)`
  Returns a target for annotations on a class type parameter declaration.
  `static TypeAnnotation.TypeParameterBoundTargetPREVIEW`
  `ofClassTypeParameterBound(int typeParameterIndex, int boundIndex)`
  Returns a target for annotations on the i'th bound of the j'th type parameter declaration of a generic class, or interface.
  `static TypeAnnotation.TypeArgumentTargetPREVIEW`
  `ofConstructorInvocationTypeArgument(LabelPREVIEW target, int typeArgumentIndex)`
  Returns a target for annotations on the i'th type argument in the explicit type argument list for an explicit constructor invocation statement.
  `static TypeAnnotation.OffsetTargetPREVIEW`
  `ofConstructorReference(LabelPREVIEW target)`
  Returns a target for annotations on the type before the :: in a constructor reference expression.
  `static TypeAnnotation.TypeArgumentTargetPREVIEW`
  `ofConstructorReferenceTypeArgument(LabelPREVIEW target, int typeArgumentIndex)`
  Returns a target for annotations on the i'th type argument in the explicit type argument list for a new expression.
  `static TypeAnnotation.CatchTargetPREVIEW`
  `ofExceptionParameter(int exceptionTableIndex)`
  Returns a target for annotations on the i'th type in an exception parameter declaration.
  `static TypeAnnotation.EmptyTargetPREVIEW`
  `ofField()`
  Returns a target for annotations on the type in a field or record declaration.
  `static TypeAnnotation.OffsetTargetPREVIEW`
  `ofInstanceofExpr(LabelPREVIEW target)`
  Returns a target for annotations on the type in an instanceof expression.
  `static TypeAnnotation.LocalVarTargetPREVIEW`
  `ofLocalVariable(List<TypeAnnotation.LocalVarTargetInfoPREVIEW> table)`
  Returns a target for annotations on the type in a local variable declaration.
  `static TypeAnnotation.FormalParameterTargetPREVIEW`
  `ofMethodFormalParameter(int formalParameterIndex)`
  Returns a target for annotations on the type in a formal parameter declaration of a method, constructor, or lambda expression.
  `static TypeAnnotation.TypeArgumentTargetPREVIEW`
  `ofMethodInvocationTypeArgument(LabelPREVIEW target, int typeArgumentIndex)`
  Returns a target for annotations on the i'th type argument in the explicit type argument list for a method invocation expression.
  `static TypeAnnotation.EmptyTargetPREVIEW`
  `ofMethodReceiver()`
  Returns a target for annotations on the receiver type of a method or constructor.
  `static TypeAnnotation.OffsetTargetPREVIEW`
  `ofMethodReference(LabelPREVIEW target)`
  Returns a target for annotations on the type before the :: in a method reference expression.
  `static TypeAnnotation.TypeArgumentTargetPREVIEW`
  `ofMethodReferenceTypeArgument(LabelPREVIEW target, int typeArgumentIndex)`
  Returns a target for annotations on the i'th type argument in the explicit type argument list for a method reference expression.
  `static TypeAnnotation.EmptyTargetPREVIEW`
  `ofMethodReturn()`
  Returns a target for annotations on the return type of a method or a newly constructed object.
  `static TypeAnnotation.TypeParameterTargetPREVIEW`
  `ofMethodTypeParameter(int typeParameterIndex)`
  Returns a target for annotations on a method type parameter declaration.
  `static TypeAnnotation.TypeParameterBoundTargetPREVIEW`
  `ofMethodTypeParameterBound(int typeParameterIndex, int boundIndex)`
  Returns a target for annotations on the i'th bound of the j'th type parameter declaration of a generic method, or constructor.
  `static TypeAnnotation.OffsetTargetPREVIEW`
  `ofNewExpr(LabelPREVIEW target)`
  Returns a target for annotations on the type in a new expression.
  `static TypeAnnotation.OffsetTargetPREVIEW`
  `ofOffset(TypeAnnotation.TargetTypePREVIEW targetType, LabelPREVIEW target)`
  Returns a target for annotations on the type in an instanceof expression or a new expression, or the type before the :: in a method reference expression.
  `static TypeAnnotation.LocalVarTargetPREVIEW`
  `ofResourceVariable(List<TypeAnnotation.LocalVarTargetInfoPREVIEW> table)`
  Returns a target for annotations on the type in a local variable declared as a resource in a try-with-resources statement.
  `static TypeAnnotation.ThrowsTargetPREVIEW`
  `ofThrows(int throwsTargetIndex)`
  Returns a target for annotations on the i'th type in the throws clause of a method or constructor declaration.
  `static TypeAnnotation.TypeArgumentTargetPREVIEW`
  `ofTypeArgument(TypeAnnotation.TargetTypePREVIEW targetType, LabelPREVIEW target, int typeArgumentIndex)`
  Returns a target for annotations 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 TypeAnnotation.TypeParameterTargetPREVIEW`
  `ofTypeParameter(TypeAnnotation.TargetTypePREVIEW targetType, int typeParameterIndex)`
  Returns a target for annotations on a class or method type parameter declaration.
  `static TypeAnnotation.TypeParameterBoundTargetPREVIEW`
  `ofTypeParameterBound(TypeAnnotation.TargetTypePREVIEW targetType, int typeParameterIndex, int boundIndex)`
  Returns a target for annotations on the i'th bound of the j'th type parameter declaration of a generic class, interface, method, or constructor.
  `static TypeAnnotation.LocalVarTargetPREVIEW`
  `ofVariable(TypeAnnotation.TargetTypePREVIEW targetType, List<TypeAnnotation.LocalVarTargetInfoPREVIEW> table)`
  Returns a target for annotations on the type in a local variable declaration, including a variable declared as a resource in a try-with-resources statement.
  `default int`
  `size()`
  Returns the size of the target info.
  `TypeAnnotation.TargetTypePREVIEW`
  `targetType()`
  Returns the type of the target.

- ## Method Details

  - ### targetType

    TypeAnnotation.TargetTypePREVIEW targetType()
    Returns the type of the target.
    Returns:
      the type of the target

  - ### size

    default int size()
    Returns the size of the target info.
    Returns:
      the size of the target info

  - ### ofTypeParameter

    static TypeAnnotation.TypeParameterTargetPREVIEW ofTypeParameter(TypeAnnotation.TargetTypePREVIEW targetType, int typeParameterIndex)
    Returns a target for annotations on a class or method type parameter declaration.
    Parameters:
      `targetType` - `TypeAnnotation.TargetType.CLASS_TYPE_PARAMETER`PREVIEW or `TypeAnnotation.TargetType.METHOD_TYPE_PARAMETER`PREVIEW
      `typeParameterIndex` - specifies which type parameter declaration is annotated
    Returns:
      a target for annotations on a class or method type parameter declaration

  - ### ofClassTypeParameter

    static TypeAnnotation.TypeParameterTargetPREVIEW ofClassTypeParameter(int typeParameterIndex)
    Returns a target for annotations on a class type parameter declaration.
    Parameters:
      `typeParameterIndex` - specifies which type parameter declaration is annotated
    Returns:
      a target for annotations on a class type parameter declaration

  - ### ofMethodTypeParameter

    static TypeAnnotation.TypeParameterTargetPREVIEW ofMethodTypeParameter(int typeParameterIndex)
    Returns a target for annotations on a method type parameter declaration.
    Parameters:
      `typeParameterIndex` - specifies which type parameter declaration is annotated
    Returns:
      a target for annotations on a method type parameter declaration

  - ### ofClassExtends

    static TypeAnnotation.SupertypeTargetPREVIEW ofClassExtends(int supertypeIndex)
    Returns a target for annotations on the type of an "extends" or "implements" clause.
    Parameters:
      `supertypeIndex` - the index into the interfaces array or 65535 to indicate it is the superclass
    Returns:
      a target for annotations on the type of an "extends" or "implements" clause

  - ### ofTypeParameterBound

    static TypeAnnotation.TypeParameterBoundTargetPREVIEW ofTypeParameterBound(TypeAnnotation.TargetTypePREVIEW targetType, int typeParameterIndex, int boundIndex)
    Returns a target for annotations on the i'th bound of the j'th type parameter declaration of a generic class, interface, method, or constructor.
    Parameters:
      `targetType` - `TypeAnnotation.TargetType.CLASS_TYPE_PARAMETER_BOUND`PREVIEW or `TypeAnnotation.TargetType.METHOD_TYPE_PARAMETER_BOUND`PREVIEW
      `typeParameterIndex` - specifies which type parameter declaration is annotated
      `boundIndex` - specifies which bound of the type parameter declaration is annotated
    Returns:
      a target for annotations on the i'th bound of the j'th type parameter declaration of a generic class, interface, method, or constructor

  - ### ofClassTypeParameterBound

    static TypeAnnotation.TypeParameterBoundTargetPREVIEW ofClassTypeParameterBound(int typeParameterIndex, int boundIndex)
    Returns a target for annotations on the i'th bound of the j'th type parameter declaration of a generic class, or interface.
    Parameters:
      `typeParameterIndex` - specifies which type parameter declaration is annotated
      `boundIndex` - specifies which bound of the type parameter declaration is annotated
    Returns:
      a target for annotations on the i'th bound of the j'th type parameter declaration of a generic class, or interface

  - ### ofMethodTypeParameterBound

    static TypeAnnotation.TypeParameterBoundTargetPREVIEW ofMethodTypeParameterBound(int typeParameterIndex, int boundIndex)
    Returns a target for annotations on the i'th bound of the j'th type parameter declaration of a generic method, or constructor.
    Parameters:
      `typeParameterIndex` - specifies which type parameter declaration is annotated
      `boundIndex` - specifies which bound of the type parameter declaration is annotated
    Returns:
      a target for annotations on the i'th bound of the j'th type parameter declaration of a generic method, or constructor

  - ### of

    static TypeAnnotation.EmptyTargetPREVIEW of(TypeAnnotation.TargetTypePREVIEW targetType)
    Returns a target for annotations.
    Parameters:
      `targetType` - `TypeAnnotation.TargetType.FIELD`PREVIEW, `TypeAnnotation.TargetType.METHOD_RETURN`PREVIEW or `TypeAnnotation.TargetType.METHOD_RECEIVER`PREVIEW
    Returns:
      a target for annotations

  - ### ofField

    static TypeAnnotation.EmptyTargetPREVIEW ofField()
    Returns a target for annotations on the type in a field or record declaration.
    Returns:
      a target for annotations on the type in a field or record declaration

  - ### ofMethodReturn

    static TypeAnnotation.EmptyTargetPREVIEW ofMethodReturn()
    Returns a target for annotations on the return type of a method or a newly constructed object.
    Returns:
      a target for annotations on the return type of a method or a newly constructed object

  - ### ofMethodReceiver

    static TypeAnnotation.EmptyTargetPREVIEW ofMethodReceiver()
    Returns a target for annotations on the receiver type of a method or constructor.
    Returns:
      a target for annotations on the receiver type of a method or constructor

  - ### ofMethodFormalParameter

    static TypeAnnotation.FormalParameterTargetPREVIEW ofMethodFormalParameter(int formalParameterIndex)
    Returns a target for annotations on the type in a formal parameter declaration of a method, constructor, or lambda expression.
    Parameters:
      `formalParameterIndex` - specifies which formal parameter declaration has an annotated type
    Returns:
      a target for annotations on the type in a formal parameter declaration of a method, constructor, or lambda expression

  - ### ofThrows

    static TypeAnnotation.ThrowsTargetPREVIEW ofThrows(int throwsTargetIndex)
    Returns a target for annotations on the i'th type in the throws clause of a method or constructor declaration.
    Parameters:
      `throwsTargetIndex` - the index into the exception table of the Exceptions attribute of the method
    Returns:
      a target for annotations on the i'th type in the throws clause of a method or constructor declaration

  - ### ofVariable

    static TypeAnnotation.LocalVarTargetPREVIEW ofVariable(TypeAnnotation.TargetTypePREVIEW targetType, List<TypeAnnotation.LocalVarTargetInfoPREVIEW> table)
    Returns a target for annotations on the type in a local variable declaration, including a variable declared as a resource in a try-with-resources statement.
    Parameters:
      `targetType` - `TypeAnnotation.TargetType.LOCAL_VARIABLE`PREVIEW or `TypeAnnotation.TargetType.RESOURCE_VARIABLE`PREVIEW
      `table` - the list of local variable targets
    Returns:
      a target for annotations on the type in a local variable declaration, including a variable declared as a resource in a try-with-resources statement

  - ### ofLocalVariable

    static TypeAnnotation.LocalVarTargetPREVIEW ofLocalVariable(List<TypeAnnotation.LocalVarTargetInfoPREVIEW> table)
    Returns a target for annotations on the type in a local variable declaration.
    Parameters:
      `table` - the list of local variable targets
    Returns:
      a target for annotations on the type in a local variable declaration

  - ### ofResourceVariable

    static TypeAnnotation.LocalVarTargetPREVIEW ofResourceVariable(List<TypeAnnotation.LocalVarTargetInfoPREVIEW> table)
    Returns a target for annotations on the type in a local variable declared as a resource in a try-with-resources statement.
    Parameters:
      `table` - the list of local variable targets
    Returns:
      a target for annotations on the type in a local variable declared as a resource in a try-with-resources statement

  - ### ofExceptionParameter

    static TypeAnnotation.CatchTargetPREVIEW ofExceptionParameter(int exceptionTableIndex)
    Returns a target for annotations on the i'th type in an exception parameter declaration.
    Parameters:
      `exceptionTableIndex` - the index into the exception table of the Code attribute
    Returns:
      a target for annotations on the i'th type in an exception parameter declaration

  - ### ofOffset

    static TypeAnnotation.OffsetTargetPREVIEW ofOffset(TypeAnnotation.TargetTypePREVIEW targetType, LabelPREVIEW target)
    Returns a target for annotations on the type in an instanceof expression or a new expression, or the type before the :: in a method reference expression.
    Parameters:
      `targetType` - `TypeAnnotation.TargetType.INSTANCEOF`PREVIEW, `TypeAnnotation.TargetType.NEW`PREVIEW, `TypeAnnotation.TargetType.CONSTRUCTOR_REFERENCE`PREVIEW, or `TypeAnnotation.TargetType.METHOD_REFERENCE`PREVIEW
      `target` - the code label corresponding to the instruction
    Returns:
      a target for annotations on the type in an instanceof expression or a new expression, or the type before the :: in a method reference expression

  - ### ofInstanceofExpr

    static TypeAnnotation.OffsetTargetPREVIEW ofInstanceofExpr(LabelPREVIEW target)
    Returns a target for annotations on the type in an instanceof expression.
    Parameters:
      `target` - the code label corresponding to the instruction
    Returns:
      a target for annotations on the type in an instanceof expression

  - ### ofNewExpr

    static TypeAnnotation.OffsetTargetPREVIEW ofNewExpr(LabelPREVIEW target)
    Returns a target for annotations on the type in a new expression.
    Parameters:
      `target` - the code label corresponding to the instruction
    Returns:
      a target for annotations on the type in a new expression

  - ### ofConstructorReference

    static TypeAnnotation.OffsetTargetPREVIEW ofConstructorReference(LabelPREVIEW target)
    Returns a target for annotations on the type before the :: in a constructor reference expression.
    Parameters:
      `target` - the code label corresponding to the instruction
    Returns:
      a target for annotations on the type before the :: in a constructor reference expression

  - ### ofMethodReference

    static TypeAnnotation.OffsetTargetPREVIEW ofMethodReference(LabelPREVIEW target)
    Returns a target for annotations on the type before the :: in a method reference expression.
    Parameters:
      `target` - the code label corresponding to the instruction
    Returns:
      a target for annotations on the type before the :: in a method reference expression

  - ### ofTypeArgument

    static TypeAnnotation.TypeArgumentTargetPREVIEW ofTypeArgument(TypeAnnotation.TargetTypePREVIEW targetType, LabelPREVIEW target, int typeArgumentIndex)
    Returns a target for annotations 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.
    Parameters:
      `targetType` - `TypeAnnotation.TargetType.CAST`PREVIEW, `TypeAnnotation.TargetType.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT`PREVIEW, `TypeAnnotation.TargetType.METHOD_INVOCATION_TYPE_ARGUMENT`PREVIEW, `TypeAnnotation.TargetType.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT`PREVIEW, or `TypeAnnotation.TargetType.METHOD_REFERENCE_TYPE_ARGUMENT`PREVIEW
      `target` - the code label corresponding to the instruction
      `typeArgumentIndex` - specifies which type in the cast operator or argument is annotated
    Returns:
      a target for annotations 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

  - ### ofCastExpr

    static TypeAnnotation.TypeArgumentTargetPREVIEW ofCastExpr(LabelPREVIEW target, int typeArgumentIndex)
    Returns a target for annotations on the i'th type in a cast expression.
    Parameters:
      `target` - the code label corresponding to the instruction
      `typeArgumentIndex` - specifies which type in the cast operator is annotated
    Returns:
      a target for annotations on the i'th type in a cast expression

  - ### ofConstructorInvocationTypeArgument

    static TypeAnnotation.TypeArgumentTargetPREVIEW ofConstructorInvocationTypeArgument(LabelPREVIEW target, int typeArgumentIndex)
    Returns a target for annotations on the i'th type argument in the explicit type argument list for an explicit constructor invocation statement.
    Parameters:
      `target` - the code label corresponding to the instruction
      `typeArgumentIndex` - specifies which type in the argument is annotated
    Returns:
      a target for annotations on the i'th type argument in the explicit type argument list for an explicit constructor invocation statement

  - ### ofMethodInvocationTypeArgument

    static TypeAnnotation.TypeArgumentTargetPREVIEW ofMethodInvocationTypeArgument(LabelPREVIEW target, int typeArgumentIndex)
    Returns a target for annotations on the i'th type argument in the explicit type argument list for a method invocation expression.
    Parameters:
      `target` - the code label corresponding to the instruction
      `typeArgumentIndex` - specifies which type in the argument is annotated
    Returns:
      a target for annotations on the i'th type argument in the explicit type argument list for a method invocation expression

  - ### ofConstructorReferenceTypeArgument

    static TypeAnnotation.TypeArgumentTargetPREVIEW ofConstructorReferenceTypeArgument(LabelPREVIEW target, int typeArgumentIndex)
    Returns a target for annotations on the i'th type argument in the explicit type argument list for a new expression.
    Parameters:
      `target` - the code label corresponding to the instruction
      `typeArgumentIndex` - specifies which type in the argument is annotated
    Returns:
      a target for annotations on the i'th type argument in the explicit type argument list for a new expression

  - ### ofMethodReferenceTypeArgument

    static TypeAnnotation.TypeArgumentTargetPREVIEW ofMethodReferenceTypeArgument(LabelPREVIEW target, int typeArgumentIndex)
    Returns a target for annotations on the i'th type argument in the explicit type argument list for a method reference expression.
    Parameters:
      `target` - the code label corresponding to the instruction
      `typeArgumentIndex` - specifies which type in the argument is annotated
    Returns:
      a target for annotations on the i'th type argument in the explicit type argument list for a method reference expression