org.apache.bcel.generic

Class LocalVariableGen

public class LocalVariableGen extends Object implements InstructionTargeter, NamedAndTyped, Cloneable, Serializable

This class represents a local variable within a method. It contains its scope, name and type. The generated LocalVariable object can be obtained with getLocalVariable which needs the instruction list and the constant pool as parameters.

See Also: LocalVariable MethodGen

Constructor Summary
LocalVariableGen(int index, String name, Type type, InstructionHandle start, InstructionHandle end)
Generate a local variable that with index `index'.
Method Summary
Objectclone()
booleancontainsTarget(InstructionHandle ih)
booleanequals(Object o)
We consider to local variables to be equal, if the use the same index and are valid in the same range.
InstructionHandlegetEnd()
intgetIndex()
LocalVariablegetLocalVariable(ConstantPoolGen cp)
Get LocalVariable object.
StringgetName()
InstructionHandlegetStart()
TypegetType()
inthashCode()
voidsetEnd(InstructionHandle end)
voidsetIndex(int index)
voidsetName(String name)
voidsetStart(InstructionHandle start)
voidsetType(Type type)
StringtoString()
voidupdateTarget(InstructionHandle old_ih, InstructionHandle new_ih)

Constructor Detail

LocalVariableGen

public LocalVariableGen(int index, String name, Type type, InstructionHandle start, InstructionHandle end)
Generate a local variable that with index `index'. Note that double and long variables need two indexs. Index indices have to be provided by the user.

Parameters: index index of local variable name its name type its type start from where the instruction is valid (null means from the start) end until where the instruction is valid (null means to the end)

Method Detail

clone

public Object clone()

containsTarget

public boolean containsTarget(InstructionHandle ih)

Returns: true, if ih is target of this variable

equals

public boolean equals(Object o)
We consider to local variables to be equal, if the use the same index and are valid in the same range.

getEnd

public InstructionHandle getEnd()

getIndex

public int getIndex()

getLocalVariable

public LocalVariable getLocalVariable(ConstantPoolGen cp)
Get LocalVariable object. This relies on that the instruction list has already been dumped to byte code or or that the `setPositions' methods has been called for the instruction list. Note that for local variables whose scope end at the last instruction of the method's code, the JVM specification is ambiguous: both a start_pc+length ending at the last instruction and start_pc+length ending at first index beyond the end of the code are valid.

Parameters: cp constant pool

getName

public String getName()

getStart

public InstructionHandle getStart()

getType

public Type getType()

hashCode

public int hashCode()

Returns: a hash code value for the object.

setEnd

public void setEnd(InstructionHandle end)

setIndex

public void setIndex(int index)

setName

public void setName(String name)

setStart

public void setStart(InstructionHandle start)

setType

public void setType(Type type)

toString

public String toString()

updateTarget

public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih)

Parameters: old_ih old target, either start or end new_ih new target