org.objectweb.asm.attrs
Class LocalVariableTypeTableAttribute
java.lang.Object
org.objectweb.asm.Attribute
org.objectweb.asm.attrs.LocalVariableTypeTableAttribute
- Direct Known Subclasses:
- ASMLocalVariableTypeTableAttribute
public class LocalVariableTypeTableAttribute
- extends Attribute
The LocalVariableTypeTable attribute is an optional variable-length attribute of a Code
attribute. It may be used by debuggers to determine the value of a given
local variable during the execution of a method. If LocalVariableTypeTable attributes
are present in the attributes table of a given Code attribute, then they may appear in
any order. There may be no more than one LocalVariableTypeTable attribute per local
variable in the Code attribute.
The LocalVariableTypeTable attribute differs from the LocalVariableTable attribute in that
it provides signature information rather than descriptor information. This difference
is only significant for variables whose type is a generic reference type. Such
variables will appear in both tables, while variables of other types will appear only
in LocalVariableTable.
The LocalVariableTypeTable attribute has the following format:
LocalVariableTypeTable_attribute {
u2 attribute_name_index;
u4 attribute_length;
u2 local_variable_type_table_length;
{
u2 start_pc;
u2 length;
u2 name_index;
u2 signature_index;
u2 index;
} local_variable_type_table[local_variable_type_table_length];
}
The items of the LocalVariableTypeTable_attribute structure are as follows:
- attribute_name_index
- The value of the attribute_name_index item must be a valid index
into the constant_pool table a121. The constant_pool entry at that
index must be a CONSTANT_Utf8_info (4.5.7) a122 structure
representing the string "LocalVariableTypeTable" a123.
- attribute_length
- The value of the attribute_length item indicates the length of the
attribute, excluding the initial six bytes.
- local_variable_table_length
- The value of the local_variable_table_length item indicates the
number of entries in the local_variable_table array.
- local_variable_table[]
- Each entry in the local_variable_table array indicates a range of code
array offsets within which a local variable has a value. It also
indicates the index into the local variable array of the current
frame at which that local variable can be found. Each entry must
contain the following five items:
- start_pc, length
- The given local variable must have a value at indices into the
code array in the interval [start_pc, start_pc+length), that is,
between start_pc and start_pc+length exclusive. The value of
start_pc must be a valid index into the code array of this Code
attribute and must be the index of the opcode of an
instructiona124. The value of start_pc+length must either be a
valid index into the code array of this Code attribute and be
the index of the opcode of an instruction, or it must be the
first index beyond the end of that code array a125.
- name_index, signature_index
- The value of the name_index item must be a valid index into
the constant_pool table a127. The constant_pool entry at that
index must contain a CONSTANT_Utf8_info structure
a128 representing a valid unqualified name denoting a local variablea128.
Careful here - do we want any restrictions at all?
The value of the signature_index item must be a valid index
into the constant_pool table. The constant_pool entry at that index
must contain a CONSTANT_Utf8_info structure
representing a field type signature encoding the type
of a local variable in the source program.
- index
- The given local variable must be at index in the local variable
array of the current frame. If the local variable at index is of
type double or long, it occupies both index and index+1.
- Author:
- Eugene Kuleshov
types
protected List types
LocalVariableTypeTableAttribute
public LocalVariableTypeTableAttribute()
getTypes
public List getTypes()
getLabels
protected Label[] getLabels()
- Description copied from class:
Attribute
- Returns the labels corresponding to this attribute.
- Overrides:
getLabels
in class Attribute
- Returns:
- the labels corresponding to this attribute, or null if
this attribute is not a code attribute that contains labels.
read
protected Attribute read(ClassReader cr,
int off,
int len,
char[] buf,
int codeOff,
Label[] labels)
- Description copied from class:
Attribute
- Reads a
type
attribute. This method must return a new
Attribute
object, of type type
, corresponding to the
len bytes starting at the given offset, in the given class reader.
- Overrides:
read
in class Attribute
- Parameters:
cr
- the class that contains the attribute to be read.off
- index of the first byte of the attribute's content in cr.b
. The 6 attribute header bytes, containing the type
and the length of the attribute, are not taken into account here.len
- the length of the attribute's content.buf
- buffer to be used to call readUTF8
,
readClass
or readConst
.codeOff
- index of the first byte of code's attribute content in
cr.b
, or -1 if the attribute to be read is not a
code attribute. The 6 attribute header bytes, containing the type and
the length of the attribute, are not taken into account here.labels
- the labels of the method's code, or null if the
attribute to be read is not a code attribute.
- Returns:
- a new
Attribute
object corresponding to the given
bytes.
write
protected ByteVector write(ClassWriter cw,
byte[] code,
int len,
int maxStack,
int maxLocals)
- Description copied from class:
Attribute
- Returns the byte array form of this attribute.
- Overrides:
write
in class Attribute
- Parameters:
cw
- the class to which this attribute must be added. This parameter
can be used to add to the constant pool of this class the items that
corresponds to this attribute.code
- the bytecode of the method corresponding to this code
attribute, or null if this attribute is not a code
attributes.len
- the length of the bytecode of the method corresponding to this
code attribute, or null if this attribute is not a code
attribute.maxStack
- the maximum stack size of the method corresponding to this
code attribute, or -1 if this attribute is not a code attribute.maxLocals
- the maximum number of local variables of the method
corresponding to this code attribute, or -1 if this attribute is not
a code attribute.
- Returns:
- the byte array form of this attribute.
toString
public String toString()
- Overrides:
toString
in class Object