ClassFileElement, CodeElement, PseudoInstructionpublic sealed interface LocalVariable extends PseudoInstruction
LocalVariableTable 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 entry is composite:
LocalVariable(
int slot,
String name,
ClassDesc type,
Label startScope,
Label endScope
)
slot is within [0, 65535]. Another model, LocalVariableInfo, also models a local variable entry; it has no dependency on a CodeModel and represents of bci values as ints instead of Labels, and is used as components of a LocalVariableTableAttribute.
LocalVariable is used for all local variables in Java source code. If a local variable has a parameterized type, a type argument, or an array type of one of the previous types, a LocalVariableType should be created for that local variable as well.| Modifier and Type | Method | Description |
|---|---|---|
Label |
endScope() |
Returns the end range of the local variable scope. |
Utf8Entry |
name() |
Returns the local variable name. |
static LocalVariable |
of |
Returns a local variable pseudo-instruction. |
static LocalVariable |
of |
Returns a local variable pseudo-instruction. |
int |
slot() |
Returns the local variable slot. |
Label |
startScope() |
Returns the start range of the local variable scope. |
Utf8Entry |
type() |
Returns the local variable field descriptor string. |
default ClassDesc |
typeSymbol() |
Returns the local variable type, as a symbolic descriptor. |
int slot()
[0, 65535].Utf8Entry name()
Utf8Entry type()
typeSymbol().default ClassDesc typeSymbol()
Label startScope()
Label endScope()
static LocalVariable of(int slot, Utf8Entry nameEntry, Utf8Entry descriptorEntry, Label startScope, Label endScope)
slot must be within [0, 65535].slot - the local variable slotnameEntry - the local variable namedescriptorEntry - the local variable descriptorstartScope - the start range of the local variable scopeendScope - the end range of the local variable scopeIllegalArgumentException - if slot is out of rangestatic LocalVariable of(int slot, String name, ClassDesc descriptor, Label startScope, Label endScope)
slot must be within [0, 65535].slot - the local variable slotname - the local variable namedescriptor - the local variable descriptorstartScope - the start range of the local variable scopeendScope - the end range of the local variable scopeIllegalArgumentException - if slot is out of range
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/classfile/instruction/LocalVariable.html