Package javassist.bytecode
Class LocalVariableAttribute
java.lang.Object
javassist.bytecode.AttributeInfo
javassist.bytecode.LocalVariableAttribute
- Direct Known Subclasses:
LocalVariableTypeAttribute
LocalVariableTable_attribute
.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The name of this attribute"LocalVariableTable"
.static final String
The name of the attribute"LocalVariableTypeTable"
.Fields inherited from class javassist.bytecode.AttributeInfo
constPool, info, name
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty LocalVariableTable.LocalVariableAttribute
(ConstPool cp, int n, DataInputStream in) LocalVariableAttribute
(ConstPool cp, String name) Deprecated.LocalVariableAttribute
(ConstPool cp, String name, byte[] i) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEntry
(int startPc, int length, int nameIndex, int descriptorIndex, int index) Appends a new entry tolocal_variable_table
.int
codeLength
(int i) Returnslocal_variable_table[i].length
.Makes a copy.descriptor
(int i) Returns the type descriptor of the local variable specified bylocal_variable_table[i].descriptor_index
.int
descriptorIndex
(int i) Returns the value oflocal_variable_table[i].descriptor_index
.int
index
(int i) Returnslocal_variable_table[i].index
.(package private) LocalVariableAttribute
makeThisAttr
(ConstPool cp, byte[] dest) int
nameIndex
(int i) Returns the value oflocal_variable_table[i].name_index
.(package private) void
renameClass
(String oldname, String newname) (package private) void
renameClass
(Map<String, String> classnames) (package private) String
renameEntry
(String desc, String oldname, String newname) (package private) String
renameEntry
(String desc, Map<String, String> classnames) void
shiftIndex
(int lessThan, int delta) For eachlocal_variable_table[i].index
, this method increasesindex
bydelta
.(package private) void
shiftPc
(int where, int gapLength, boolean exclusive) Adjusts start_pc and length if bytecode is inserted in a method body.signature
(int i) This method is equivalent todescriptor()
.int
signatureIndex
(int i) This method is equivalent todescriptorIndex()
.int
startPc
(int i) Returnslocal_variable_table[i].start_pc
.int
Returnslocal_variable_table_length
.variableName
(int i) Returns the name of the local variable specified bylocal_variable_table[i].name_index
.variableNameByIndex
(int index) Returns the name of the local variable with given index.Methods inherited from class javassist.bytecode.AttributeInfo
copyAll, get, getConstPool, getLength, getName, getRefClasses, getRefClasses, length, lookup, read, remove, renameClass, renameClass, set, write, writeAll
-
Field Details
-
tag
The name of this attribute"LocalVariableTable"
.- See Also:
-
typeTag
The name of the attribute"LocalVariableTypeTable"
.- See Also:
-
-
Constructor Details
-
LocalVariableAttribute
Constructs an empty LocalVariableTable. -
LocalVariableAttribute
Deprecated.Constructs an empty LocalVariableTable.- Parameters:
name
- the attribute name.LocalVariableAttribute.tag
orLocalVariableAttribute.typeTag
.- Since:
- 3.1
- See Also:
-
LocalVariableAttribute
LocalVariableAttribute(ConstPool cp, int n, DataInputStream in) throws IOException - Throws:
IOException
-
LocalVariableAttribute
-
-
Method Details
-
addEntry
public void addEntry(int startPc, int length, int nameIndex, int descriptorIndex, int index) Appends a new entry tolocal_variable_table
.- Parameters:
startPc
-start_pc
length
-length
nameIndex
-name_index
descriptorIndex
-descriptor_index
index
-index
-
renameClass
- Overrides:
renameClass
in classAttributeInfo
-
renameEntry
-
renameClass
- Overrides:
renameClass
in classAttributeInfo
-
renameEntry
-
shiftIndex
public void shiftIndex(int lessThan, int delta) For eachlocal_variable_table[i].index
, this method increasesindex
bydelta
.- Parameters:
lessThan
- the index does not change if it is less than this value.
-
tableLength
public int tableLength()Returnslocal_variable_table_length
. This represents the number of entries in the table. -
startPc
public int startPc(int i) Returnslocal_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.
-
codeLength
public int codeLength(int i) Returnslocal_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.
-
shiftPc
void shiftPc(int where, int gapLength, boolean exclusive) Adjusts start_pc and length if bytecode is inserted in a method body. -
nameIndex
public int nameIndex(int i) Returns the value oflocal_variable_table[i].name_index
. This represents the name of the local variable.- Parameters:
i
- the i-th entry.
-
variableName
Returns the name of the local variable specified bylocal_variable_table[i].name_index
.- Parameters:
i
- the i-th entry.
-
variableNameByIndex
Returns the name of the local variable with given index. If you want to get the parameter name of method with correct order, you should using this method.- Parameters:
index
- the index of the local variable.
-
descriptorIndex
public int descriptorIndex(int i) Returns the value oflocal_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.
-
signatureIndex
public int signatureIndex(int i) This method is equivalent todescriptorIndex()
. If this attribute represents a LocalVariableTypeTable attribute, this method should be used instead ofdescriptorIndex()
since the method name is more appropriate.- Parameters:
i
- the i-th entry.- See Also:
-
descriptor
Returns the type descriptor of the local variable specified bylocal_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.
-
signature
This method is equivalent todescriptor()
. If this attribute represents a LocalVariableTypeTable attribute, this method should be used instead ofdescriptor()
since the method name is more appropriate.To parse the string, call
toFieldSignature(String)
inSignatureAttribute
.- Parameters:
i
- the i-th entry.- See Also:
-
index
public int index(int i) Returnslocal_variable_table[i].index
. This represents the index of the local variable.- Parameters:
i
- the i-th entry.
-
copy
Makes a copy.- Overrides:
copy
in classAttributeInfo
- Parameters:
newCp
- the constant pool table used by the new copy.classnames
- should be null.
-
makeThisAttr
-