javassist.bytecode

Class LocalVariableAttribute

public class LocalVariableAttribute extends AttributeInfo

LocalVariableTable_attribute or LocalVariableTypeTable_attribute.
Field Summary
static Stringtag
The name of this attribute "LocalVariableTable".
static StringtypeTag
The name of the attribute "LocalVariableTypeTable".
Constructor Summary
LocalVariableAttribute(ConstPool cp)
Constructs an empty LocalVariableTable.
LocalVariableAttribute(ConstPool cp, String name)
Constructs an empty LocalVariableTable.
Method Summary
voidaddEntry(int startPc, int length, int nameIndex, int descriptorIndex, int index)
Appends a new entry to local_variable_table.
intcodeLength(int i)
Returns local_variable_table[i].length.
AttributeInfocopy(ConstPool newCp, Map classnames)
Makes a copy.
Stringdescriptor(int i)
Returns the type descriptor of the local variable specified by local_variable_table[i].descriptor_index.
intdescriptorIndex(int i)
Returns the value of local_variable_table[i].descriptor_index.
intindex(int i)
Returns local_variable_table[i].index.
intnameIndex(int i)
Returns the value of local_variable_table[i].name_index.
Stringsignature(int i)
This method is equivalent to descriptor().
intsignatureIndex(int i)
This method is equivalent to descriptorIndex().
intstartPc(int i)
Returns local_variable_table[i].start_pc.
inttableLength()
Returns local_variable_table_length.
StringvariableName(int i)
Returns the name of the local variable specified by local_variable_table[i].name_index.

Field Detail

tag

public static final String tag
The name of this attribute "LocalVariableTable".

typeTag

public static final String typeTag
The name of the attribute "LocalVariableTypeTable".

Constructor Detail

LocalVariableAttribute

public LocalVariableAttribute(ConstPool cp)
Constructs an empty LocalVariableTable.

LocalVariableAttribute

public LocalVariableAttribute(ConstPool cp, String name)
Constructs an empty LocalVariableTable.

Parameters: name the attribute name. LocalVariableAttribute.tag or LocalVariableAttribute.typeTag.

Since: 3.1

See Also: tag typeTag

Method Detail

addEntry

public void addEntry(int startPc, int length, int nameIndex, int descriptorIndex, int index)
Appends a new entry to local_variable_table.

Parameters: startPc start_pc length length nameIndex name_index descriptorIndex descriptor_index index index

codeLength

public int codeLength(int i)
Returns local_variable_table[i].length. This represents the length of the code region in which the local variable is effective.

Parameters: i the i-th entry.

copy

public AttributeInfo copy(ConstPool newCp, Map classnames)
Makes a copy.

Parameters: newCp the constant pool table used by the new copy. classnames should be null.

descriptor

public String descriptor(int i)
Returns the type descriptor of the local variable specified by local_variable_table[i].descriptor_index.

If this attribute represents a LocalVariableTypeTable attribute, this method returns the type signature of the local variable specified by local_variable_type_table[i].signature_index.

Parameters: i the i-th entry.

descriptorIndex

public int descriptorIndex(int i)
Returns the value of local_variable_table[i].descriptor_index. This represents the type descriptor of the local variable.

If this attribute represents a LocalVariableTypeTable attribute, this method returns the value of local_variable_type_table[i].signature_index. It represents the type of the local variable.

Parameters: i the i-th entry.

index

public int index(int i)
Returns local_variable_table[i].index. This represents the index of the local variable.

Parameters: i the i-th entry.

nameIndex

public int nameIndex(int i)
Returns the value of local_variable_table[i].name_index. This represents the name of the local variable.

Parameters: i the i-th entry.

signature

public String signature(int i)
This method is equivalent to descriptor(). If this attribute represents a LocalVariableTypeTable attribute, this method should be used instead of descriptor() since the method name is more appropriate.

To parse the string, call toFieldSignature(String) in SignatureAttribute.

Parameters: i the i-th entry.

See Also: LocalVariableAttribute toFieldSignature

signatureIndex

public int signatureIndex(int i)
This method is equivalent to descriptorIndex(). If this attribute represents a LocalVariableTypeTable attribute, this method should be used instead of descriptorIndex() since the method name is more appropriate.

Parameters: i the i-th entry.

See Also: LocalVariableAttribute toFieldSignature

startPc

public int startPc(int i)
Returns local_variable_table[i].start_pc. This represents the index into the code array from which the local variable is effective.

Parameters: i the i-th entry.

tableLength

public int tableLength()
Returns local_variable_table_length. This represents the number of entries in the table.

variableName

public String variableName(int i)
Returns the name of the local variable specified by local_variable_table[i].name_index.

Parameters: i the i-th entry.

Javassist, a Java-bytecode translator toolkit.
Copyright (C) 1999-2006 Shigeru Chiba. All Rights Reserved.