Spec-Zone.ru › OpenJDK 27

Interface LocalVariable

All Superinterfaces:
ClassFileElement, CodeElement, PseudoInstruction
public sealed interface LocalVariable extends PseudoInstruction
A pseudo-instruction which models a single entry in the 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
)
Where slot is u2.

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.

API Note:
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.
Since:
24
See Also:
  • LocalVariableInfo
  • CodeBuilder::localVariable
  • 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 LocalVariable of(int slot, Utf8Entry nameEntry, Utf8Entry descriptorEntry, Label startScope, Label endScope)
Returns a local variable pseudo-instruction.
static LocalVariable of(int slot, String name, ClassDesc descriptor, Label startScope, Label endScope)
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.

Method Details

slot

int slot()
Returns the local variable slot. It is a u2 value.
Returns:
the local variable slot

name

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

type

Utf8Entry type()
Returns the local variable field descriptor string.
API Note:
A symbolic descriptor for the type of the local variable is available through typeSymbol().
Returns:
the local variable field descriptor string

typeSymbol

default ClassDesc typeSymbol()
Returns the local variable type, as a symbolic descriptor.
Returns:
the local variable type, as a symbolic descriptor

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 LocalVariable of(int slot, Utf8Entry nameEntry, Utf8Entry descriptorEntry, Label startScope, Label endScope)
Returns a local variable pseudo-instruction. slot must be u2.
Parameters:
slot - the local variable slot
nameEntry - the local variable name
descriptorEntry - the local variable descriptor
startScope - the start range of the local variable scope
endScope - the end range of the local variable scope
Returns:
a local variable pseudo-instruction
Throws:
IllegalArgumentException - if slot is not u2

of

static LocalVariable of(int slot, String name, ClassDesc descriptor, Label startScope, Label endScope)
Returns a local variable pseudo-instruction. slot must be u2.
Parameters:
slot - the local variable slot
name - the local variable name
descriptor - the local variable descriptor
startScope - the start range of the local variable scope
endScope - the end range of the local variable scope
Returns:
a local variable pseudo-instruction
Throws:
IllegalArgumentException - if slot is not u2

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2026, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

© 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.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API