LocalVariableType (Java SE 25 & JDK 25)
Description: declaration: module: java.base, package: java.lang.classfile.instruction, interface: LocalVariableType
Keywords: java.lang.classfile.instruction.LocalVariableType interface

# Interface LocalVariableType

All Superinterfaces:
  `ClassFileElement, CodeElement, PseudoInstruction`

public sealed interface LocalVariableType extends PseudoInstruction
A pseudo-instruction which models a single entry in the `LocalVariableTypeTable` attribute. Delivered as a `CodeElement` during traversal of the elements of a `CodeModel`, according to the setting of the `ClassFile.DebugElementsOption` option.

A local variable type entry is composite:

    LocalVariableType(
        int slot,
        String name,
        Signature signature,
        Label startScope,
        Label endScope
    )

Where `slot` is within `[0, 65535]`.

Another model, `LocalVariableTypeInfo`, also models a local variable type entry; it has no dependency on a `CodeModel` and represents of bci values as `int`s instead of `Label`s, and is used as components of a `LocalVariableTypeTableAttribute`.

API Note:
  `LocalVariableType` is used if a local variable has a parameterized type, a type argument, or an array type of one of the previous types as its type. A `LocalVariable` with the erased type should still be created for that local variable.
Since:
  24
See Also:
  - `LocalVariableTypeInfo`
  - `CodeBuilder::localVariableType`
  - `ClassFile.DebugElementsOption`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Label`
  `endScope()`
  Returns the end range of the local variable scope.
  `Utf8Entry`
  `name()`
  Returns the local variable name.
  `static LocalVariableType`
  `of(int slot, Utf8Entry nameEntry, Utf8Entry signatureEntry, Label startScope, Label endScope)`
  Returns a local variable type pseudo-instruction.
  `static LocalVariableType`
  `of(int slot, String name, Signature signature, Label startScope, Label endScope)`
  Returns a local variable type pseudo-instruction.
  `Utf8Entry`
  `signature()`
  Returns the local variable generic signature string.
  `default Signature`
  `signatureSymbol()`
  Returns the local variable generic signature.
  `int`
  `slot()`
  Returns the local variable slot.
  `Label`
  `startScope()`
  Returns the start range of the local variable scope.

- ## Method Details

  - ### slot

    int slot()
    Returns the local variable slot. The value is within `[0, 65535]`.
    Returns:
      the local variable slot

  - ### name

    Utf8Entry name()
    Returns the local variable name.
    Returns:
      the local variable name

  - ### signature

    Utf8Entry signature()
    Returns the local variable generic signature string.
    API Note:
      A symbolic generic signature of the local variable is available through `signatureSymbol()`.
    Returns:
      the local variable generic signature string

  - ### signatureSymbol

    default Signature signatureSymbol()
    Returns the local variable generic signature.
    Returns:
      the local variable generic signature

  - ### startScope

    Label startScope()
    Returns the start range of the local variable scope.
    Returns:
      the start range of the local variable scope

  - ### endScope

    Label endScope()
    Returns the end range of the local variable scope.
    Returns:
      the end range of the local variable scope

  - ### of

    static LocalVariableType of(int slot, Utf8Entry nameEntry, Utf8Entry signatureEntry, Label startScope, Label endScope)
    Returns a local variable type pseudo-instruction. `slot` must be within `[0, 65535]`.
    Parameters:
      `slot` - the local variable slot
      `nameEntry` - the local variable name
      `signatureEntry` - the local variable signature
      `startScope` - the start range of the local variable scope
      `endScope` - the end range of the local variable scope
    Returns:
      a local variable type pseudo-instruction
    Throws:
      `IllegalArgumentException` - if `slot` is out of range

  - ### of

    static LocalVariableType of(int slot, String name, Signature signature, Label startScope, Label endScope)
    Returns a local variable type pseudo-instruction. `slot` must be within `[0, 65535]`.
    Parameters:
      `slot` - the local variable slot
      `name` - the local variable name
      `signature` - the local variable signature
      `startScope` - the start range of the local variable scope
      `endScope` - the end range of the local variable scope
    Returns:
      a local variable type pseudo-instruction
    Throws:
      `IllegalArgumentException` - if `slot` is out of range