APIdia Launch Partner
Top Description Methods
java.lang.classfile.instruction

public sealed Interface LocalVariable

extends PseudoInstruction
permits UnboundLocalVariable, BoundLocalVariable
Known Direct Implementers
jdk.internal.classfile.impl.AbstractPseudoInstruction.UnboundLocalVariable, jdk.internal.classfile.impl.BoundLocalVariable
Imports
java.lang.classfile.ClassFile, .CodeBuilder, .CodeElement, .CodeModel, .Label, .PseudoInstruction, java.lang.classfile.attribute.LocalVariableInfo, .LocalVariableTableAttribute, java.lang.classfile.constantpool.Utf8Entry, java.lang.constant.ClassDesc, jdk.internal.classfile.impl.AbstractPseudoInstruction, .BoundLocalVariable, .TemporaryConstantPool, .Util

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 )
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 TypeMethod and Description
public Label

Returns:

the end range of the local variable scope
endScope
()

Returns the end range of the local variable scope.

public Utf8Entry

Returns:

the local variable name
name
()

Returns the local variable name.

public static LocalVariable

Returns:

a local variable pseudo-instruction
of
(int
the local variable slot
slot
,
Utf8Entry
the local variable name
nameEntry
,
Utf8Entry
the local variable descriptor
descriptorEntry
,
Label
the start range of the local variable scope
startScope
,
Label
the end range of the local variable scope
endScope
)

Returns a local variable pseudo-instruction.

public static LocalVariable

Returns:

a local variable pseudo-instruction
of
(int
the local variable slot
slot
,
String
the local variable name
name
,
ClassDesc
the local variable descriptor
descriptor
,
Label
the start range of the local variable scope
startScope
,
Label
the end range of the local variable scope
endScope
)

Returns a local variable pseudo-instruction.

public int

Returns:

the local variable slot
slot
()

Returns the local variable slot.

public Label

Returns:

the start range of the local variable scope
startScope
()

Returns the start range of the local variable scope.

public Utf8Entry

Returns:

the local variable field descriptor string
type
()

Returns the local variable field descriptor string.

public default ClassDesc

Returns:

the local variable type, as a symbolic descriptor
typeSymbol
()

Returns the local variable type, as a symbolic descriptor.

Method Detail

endScopeback to summary
public Label endScope()

Returns the end range of the local variable scope.

Returns:Label

the end range of the local variable scope

nameback to summary
public Utf8Entry name()

Returns the local variable name.

Returns:Utf8Entry

the local variable name

ofback to summary
public 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:int

the local variable slot

nameEntry:Utf8Entry

the local variable name

descriptorEntry:Utf8Entry

the local variable descriptor

startScope:Label

the start range of the local variable scope

endScope:Label

the end range of the local variable scope

Returns:LocalVariable

a local variable pseudo-instruction

Exceptions
IllegalArgumentException:
if slot is not u2
ofback to summary
public 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:int

the local variable slot

name:String

the local variable name

descriptor:ClassDesc

the local variable descriptor

startScope:Label

the start range of the local variable scope

endScope:Label

the end range of the local variable scope

Returns:LocalVariable

a local variable pseudo-instruction

Exceptions
IllegalArgumentException:
if slot is not u2
slotback to summary
public int slot()

Returns the local variable slot. It is a u2 value.

Returns:int

the local variable slot

startScopeback to summary
public Label startScope()

Returns the start range of the local variable scope.

Returns:Label

the start range of the local variable scope

typeback to summary
public 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:Utf8Entry

the local variable field descriptor string

typeSymbolback to summary
public default ClassDesc typeSymbol()

Returns the local variable type, as a symbolic descriptor.

Returns:ClassDesc

the local variable type, as a symbolic descriptor