Top Description Fields Constructors Methods
org.apache.bcel.classfile

public final Class LocalVariable

extends Object
implements Cloneable, Node, Constants
Class Inheritance
All Implemented Interfaces
org.apache.bcel.Constants, org.apache.bcel.classfile.Node, java.lang.Cloneable
Imports
java.io.DataInput, .DataOutputStream, .IOException, org.apache.bcel.Constants, org.apache.bcel.util.Args

Deprecated

as a consequence of Constants being deprecated. See corresponding docs for further information.

This class represents a local variable within a method. It contains its scope, name, signature and index on the method's frame. It is used both to represent an element of the LocalVariableTable as well as an element of the LocalVariableTypeTable. The nomenclature used here may be a bit confusing; while the two items have the same layout in a class file, a LocalVariableTable attribute contains a descriptor_index, not a signatureIndex. The LocalVariableTypeTable attribute does have a signatureIndex.
See Also
{@link org.apache.bcel.classfile.Utility} for more details on the difference., LocalVariableTable, LocalVariableTypeTable

Field Summary

Modifier and TypeField and Description
private ConstantPool
pack-priv static final LocalVariable[]
EMPTY_ARRAY

Deprecated as a consequence of LocalVariable being deprecated.
private int
private int
private int
nameIndex

Index in constant pool of variable name.

private final int
origIndex

Never changes; used to match up with LocalVariableTypeTable entries.

private int
signatureIndex

Technically, a decscriptor_index for a local variable table entry and a signatureIndex for a local variable type table entry.

private int
startPc

Range in which the variable is valid.

Constructor Summary

AccessConstructor and Description
pack-priv
LocalVariable(final DataInput
Input stream
file
,
final ConstantPool constantPool)

Constructs object from file stream.

public
LocalVariable(final int
Range in which the variable
startPc
,
final int
... is valid
length
,
final int
Index in constant pool of variable name
nameIndex
,
final int
Index of variable's signature
signatureIndex
,
final int
Variable is 'index'th local variable on the method's frame
index
,
final ConstantPool
Array of constants
constantPool
)

public
LocalVariable(final int
Range in which the variable
startPc
,
final int
... is valid
length
,
final int
Index in constant pool of variable name
nameIndex
,
final int
Index of variable's signature
signatureIndex
,
final int
Variable is 'index'th local variable on the method's frame
index
,
final ConstantPool
Array of constants
constantPool
,
final int
Variable is 'index'th local variable on the method's frame prior to any changes
origIndex
)

public
LocalVariable(final LocalVariable
Another LocalVariable.
localVariable
)

Deprecated as a consequence of LocalVariable being deprecated.
Initializes from another LocalVariable.

Method Summary

Modifier and TypeMethod and Description
public void
accept(final Visitor
Visitor object
v
)

Implements org.apache.bcel.classfile.Node.accept.

Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
public LocalVariable

Returns:

deep copy of this object
copy
()

Deprecated as a consequence of LocalVariable being deprecated.
public void
dump(final DataOutputStream
Output file stream
dataOutputStream
)

Dumps local variable to file stream in binary format.

public ConstantPool

Returns:

Constant pool used by this object.
getConstantPool
()

public int

Returns:

index of register where variable is stored
getIndex
()

public int

Returns:

Variable is valid within getStartPC() .. getStartPC()+getLength()
getLength
()

public String

Returns:

Variable name.
getName
()

public int

Returns:

Index in constant pool of variable name.
getNameIndex
()

public int

Returns:

index of register where variable was originally stored
getOrigIndex
()

public String

Returns:

Signature.
getSignature
()

public int

Returns:

Index in constant pool of variable signature.
getSignatureIndex
()

public int

Returns:

Start of range where the variable is valid
getStartPC
()

public void
setConstantPool(final ConstantPool
Constant pool to be used for this object.
constantPool
)

public void
setIndex(final int
the index in the local variable table of this variable
index
)

public void
setLength(final int
the length of this local variable
length
)

public void
setNameIndex(final int
the index into the constant pool for the name of this variable
nameIndex
)

public void
setSignatureIndex(final int
the index into the constant pool for the signature of this variable
signatureIndex
)

public void
setStartPC(final int
Specify range where the local variable is valid.
startPc
)

public String

Returns:

string representation.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
pack-priv String
toStringShared(final boolean typeTable)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

constantPoolback to summary
private ConstantPool constantPool
EMPTY_ARRAYback to summary
pack-priv static final LocalVariable[] EMPTY_ARRAY

Deprecated

as a consequence of LocalVariable being deprecated. See corresponding docs for further information.

indexback to summary
private int index
lengthback to summary
private int length
nameIndexback to summary
private int nameIndex

Index in constant pool of variable name.

origIndexback to summary
private final int origIndex

Never changes; used to match up with LocalVariableTypeTable entries.

signatureIndexback to summary
private int signatureIndex

Technically, a decscriptor_index for a local variable table entry and a signatureIndex for a local variable type table entry. Index of variable signature

startPcback to summary
private int startPc

Range in which the variable is valid.

Constructor Detail

LocalVariableback to summary
pack-priv LocalVariable(final DataInput file, final ConstantPool constantPool) throws IOException

Constructs object from file stream.

Parameters
file:DataInput

Input stream

Exceptions
IOException:
if an I/O error occurs.
LocalVariableback to summary
public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index, final ConstantPool constantPool)
Parameters
startPc:int

Range in which the variable

length:int

... is valid

nameIndex:int

Index in constant pool of variable name

signatureIndex:int

Index of variable's signature

index:int

Variable is 'index'th local variable on the method's frame

constantPool:ConstantPool

Array of constants

LocalVariableback to summary
public LocalVariable(final int startPc, final int length, final int nameIndex, final int signatureIndex, final int index, final ConstantPool constantPool, final int origIndex)
Parameters
startPc:int

Range in which the variable

length:int

... is valid

nameIndex:int

Index in constant pool of variable name

signatureIndex:int

Index of variable's signature

index:int

Variable is 'index'th local variable on the method's frame

constantPool:ConstantPool

Array of constants

origIndex:int

Variable is 'index'th local variable on the method's frame prior to any changes

LocalVariableback to summary
public LocalVariable(final LocalVariable localVariable)

Deprecated

as a consequence of LocalVariable being deprecated. See corresponding docs for further information.

Initializes from another LocalVariable. Note that both objects use the same references (shallow copy). Use copy() for a physical copy.

Parameters
localVariable:LocalVariable

Another LocalVariable.

Method Detail

acceptback to summary
public void accept(final Visitor v)

Implements org.apache.bcel.classfile.Node.accept.

Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.

Parameters
v:Visitor

Visitor object

Annotations
@Override
copyback to summary
public LocalVariable copy()

Deprecated

as a consequence of LocalVariable being deprecated. See corresponding docs for further information.

Returns:LocalVariable

deep copy of this object

dumpback to summary
public void dump(final DataOutputStream dataOutputStream) throws IOException

Dumps local variable to file stream in binary format.

Parameters
dataOutputStream:DataOutputStream

Output file stream

Exceptions
IOException:
if an I/O error occurs.
See Also
java.io.FilterOutputStream#out
getConstantPoolback to summary
public ConstantPool getConstantPool()
Returns:ConstantPool

Constant pool used by this object.

getIndexback to summary
public int getIndex()
Returns:int

index of register where variable is stored

getLengthback to summary
public int getLength()
Returns:int

Variable is valid within getStartPC() .. getStartPC()+getLength()

getNameback to summary
public String getName()
Returns:String

Variable name.

getNameIndexback to summary
public int getNameIndex()
Returns:int

Index in constant pool of variable name.

getOrigIndexback to summary
public int getOrigIndex()
Returns:int

index of register where variable was originally stored

getSignatureback to summary
public String getSignature()
Returns:String

Signature.

getSignatureIndexback to summary
public int getSignatureIndex()
Returns:int

Index in constant pool of variable signature.

getStartPCback to summary
public int getStartPC()
Returns:int

Start of range where the variable is valid

setConstantPoolback to summary
public void setConstantPool(final ConstantPool constantPool)
Parameters
constantPool:ConstantPool

Constant pool to be used for this object.

setIndexback to summary
public void setIndex(final int index)
Parameters
index:int

the index in the local variable table of this variable

setLengthback to summary
public void setLength(final int length)
Parameters
length:int

the length of this local variable

setNameIndexback to summary
public void setNameIndex(final int nameIndex)
Parameters
nameIndex:int

the index into the constant pool for the name of this variable

setSignatureIndexback to summary
public void setSignatureIndex(final int signatureIndex)
Parameters
signatureIndex:int

the index into the constant pool for the signature of this variable

setStartPCback to summary
public void setStartPC(final int startPc)
Parameters
startPc:int

Specify range where the local variable is valid.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

string representation.

Annotations
@Override
toStringSharedback to summary
pack-priv String toStringShared(final boolean typeTable)