Package javassist.bytecode
Class LocalVariableAttribute
- java.lang.Object
-
- javassist.bytecode.AttributeInfo
-
- javassist.bytecode.LocalVariableAttribute
-
- Direct Known Subclasses:
LocalVariableTypeAttribute
public class LocalVariableAttribute extends AttributeInfo
LocalVariableTable_attribute.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringtagThe name of this attribute"LocalVariableTable".static java.lang.StringtypeTagThe name of the attribute"LocalVariableTypeTable".-
Fields inherited from class javassist.bytecode.AttributeInfo
constPool, info, name
-
-
Constructor Summary
Constructors Constructor Description LocalVariableAttribute(ConstPool cp)Constructs an empty LocalVariableTable.LocalVariableAttribute(ConstPool cp, int n, java.io.DataInputStream in)LocalVariableAttribute(ConstPool cp, java.lang.String name)Deprecated.LocalVariableAttribute(ConstPool cp, java.lang.String name, byte[] i)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEntry(int startPc, int length, int nameIndex, int descriptorIndex, int index)Appends a new entry tolocal_variable_table.intcodeLength(int i)Returnslocal_variable_table[i].length.AttributeInfocopy(ConstPool newCp, java.util.Map<java.lang.String,java.lang.String> classnames)Makes a copy.java.lang.Stringdescriptor(int i)Returns the type descriptor of the local variable specified bylocal_variable_table[i].descriptor_index.intdescriptorIndex(int i)Returns the value oflocal_variable_table[i].descriptor_index.intindex(int i)Returnslocal_variable_table[i].index.(package private) LocalVariableAttributemakeThisAttr(ConstPool cp, byte[] dest)intnameIndex(int i)Returns the value oflocal_variable_table[i].name_index.(package private) voidrenameClass(java.lang.String oldname, java.lang.String newname)(package private) voidrenameClass(java.util.Map<java.lang.String,java.lang.String> classnames)(package private) java.lang.StringrenameEntry(java.lang.String desc, java.lang.String oldname, java.lang.String newname)(package private) java.lang.StringrenameEntry(java.lang.String desc, java.util.Map<java.lang.String,java.lang.String> classnames)voidshiftIndex(int lessThan, int delta)For eachlocal_variable_table[i].index, this method increasesindexbydelta.(package private) voidshiftPc(int where, int gapLength, boolean exclusive)Adjusts start_pc and length if bytecode is inserted in a method body.java.lang.Stringsignature(int i)This method is equivalent todescriptor().intsignatureIndex(int i)This method is equivalent todescriptorIndex().intstartPc(int i)Returnslocal_variable_table[i].start_pc.inttableLength()Returnslocal_variable_table_length.java.lang.StringvariableName(int i)Returns the name of the local variable specified bylocal_variable_table[i].name_index.java.lang.StringvariableNameByIndex(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 Detail
-
tag
public static final java.lang.String tag
The name of this attribute"LocalVariableTable".- See Also:
- Constant Field Values
-
typeTag
public static final java.lang.String typeTag
The name of the attribute"LocalVariableTypeTable".- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LocalVariableAttribute
public LocalVariableAttribute(ConstPool cp)
Constructs an empty LocalVariableTable.
-
LocalVariableAttribute
@Deprecated public LocalVariableAttribute(ConstPool cp, java.lang.String name)
Deprecated.Constructs an empty LocalVariableTable.
-
LocalVariableAttribute
LocalVariableAttribute(ConstPool cp, int n, java.io.DataInputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
LocalVariableAttribute
LocalVariableAttribute(ConstPool cp, java.lang.String name, byte[] i)
-
-
Method Detail
-
addEntry
public void addEntry(int startPc, int length, int nameIndex, int descriptorIndex, int index)Appends a new entry tolocal_variable_table.- Parameters:
startPc-start_pclength-lengthnameIndex-name_indexdescriptorIndex-descriptor_indexindex-index
-
renameClass
void renameClass(java.lang.String oldname, java.lang.String newname)- Overrides:
renameClassin classAttributeInfo
-
renameEntry
java.lang.String renameEntry(java.lang.String desc, java.lang.String oldname, java.lang.String newname)
-
renameClass
void renameClass(java.util.Map<java.lang.String,java.lang.String> classnames)
- Overrides:
renameClassin classAttributeInfo
-
renameEntry
java.lang.String renameEntry(java.lang.String desc, java.util.Map<java.lang.String,java.lang.String> classnames)
-
shiftIndex
public void shiftIndex(int lessThan, int delta)For eachlocal_variable_table[i].index, this method increasesindexbydelta.- 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
public java.lang.String variableName(int i)
Returns the name of the local variable specified bylocal_variable_table[i].name_index.- Parameters:
i- the i-th entry.
-
variableNameByIndex
public java.lang.String variableNameByIndex(int index)
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:
descriptorIndex(int),SignatureAttribute.toFieldSignature(String)
-
descriptor
public java.lang.String descriptor(int i)
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
public java.lang.String signature(int i)
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:
descriptor(int),SignatureAttribute.toFieldSignature(String)
-
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
public AttributeInfo copy(ConstPool newCp, java.util.Map<java.lang.String,java.lang.String> classnames)
Makes a copy.- Overrides:
copyin classAttributeInfo- Parameters:
newCp- the constant pool table used by the new copy.classnames- should be null.
-
makeThisAttr
LocalVariableAttribute makeThisAttr(ConstPool cp, byte[] dest)
-
-