org.apache.bcel.classfile

Class LocalVariableTable

public class LocalVariableTable extends Attribute

This class represents colection of local variables in a method. This attribute is contained in the Code attribute.

Version: $Id: LocalVariableTable.java 386056 2006-03-15 11:31:56Z tcurdt $

Author: M. Dahm

See Also: Code LocalVariable

Field Summary
LocalVariable[]local_variable_table
intlocal_variable_table_length
Constructor Summary
LocalVariableTable(LocalVariableTable c)
Initialize from another object.
LocalVariableTable(int name_index, int length, LocalVariable[] local_variable_table, ConstantPool constant_pool)
LocalVariableTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
Construct object from file stream.
Method Summary
voidaccept(Visitor v)
Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.
Attributecopy(ConstantPool _constant_pool)
voiddump(DataOutputStream file)
Dump local variable table attribute to file stream in binary format.
LocalVariablegetLocalVariable(int index)
LocalVariablegetLocalVariable(int index, int pc)
LocalVariable[]getLocalVariableTable()
intgetTableLength()
voidsetLocalVariableTable(LocalVariable[] local_variable_table)
StringtoString()

Field Detail

local_variable_table

private LocalVariable[] local_variable_table

local_variable_table_length

private int local_variable_table_length

Constructor Detail

LocalVariableTable

public LocalVariableTable(LocalVariableTable c)
Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a physical copy.

LocalVariableTable

public LocalVariableTable(int name_index, int length, LocalVariable[] local_variable_table, ConstantPool constant_pool)

Parameters: name_index Index in constant pool to `LocalVariableTable' length Content length in bytes local_variable_table Table of local variables constant_pool Array of constants

LocalVariableTable

LocalVariableTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
Construct object from file stream.

Parameters: name_index Index in constant pool length Content length in bytes file Input stream constant_pool Array of constants

Throws: IOException

Method Detail

accept

public void accept(Visitor v)
Called by objects that are traversing the nodes of the tree implicitely 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 object

copy

public Attribute copy(ConstantPool _constant_pool)

Returns: deep copy of this attribute

dump

public final void dump(DataOutputStream file)
Dump local variable table attribute to file stream in binary format.

Parameters: file Output file stream

Throws: IOException

getLocalVariable

public final LocalVariable getLocalVariable(int index)

Deprecated: since 5.2 because multiple variables can share the same slot, use getLocalVariable(int index, int pc) instead.

Parameters: index the variable slot

Returns: first matching variable using index the first LocalVariable that matches the slot or null if not found

getLocalVariable

public final LocalVariable getLocalVariable(int index, int pc)

Parameters: index the variable slot pc the current pc that this variable is alive

Returns: matching variable using index when variable is used at supplied pc the LocalVariable that matches or null if not found

getLocalVariableTable

public final LocalVariable[] getLocalVariableTable()

Returns: Array of local variables of method.

getTableLength

public final int getTableLength()

setLocalVariableTable

public final void setLocalVariableTable(LocalVariable[] local_variable_table)

toString

public final String toString()

Returns: String representation.