APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.bcel.internal.generic

public Class LocalVariableGen

extends Object
implements InstructionTargeter, NamedAndTyped, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, com.sun.org.apache.bcel.internal.generic.NamedAndTyped, com.sun.org.apache.bcel.internal.generic.InstructionTargeter
Imports
com.sun.org.apache.bcel.internal.Const, com.sun.org.apache.bcel.internal.classfile.LocalVariable

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

Field Summary

Modifier and TypeField and Description
private InstructionHandle
private int
private boolean
private String
private int
private InstructionHandle
private Type

Constructor Summary

AccessConstructor and Description
public
LocalVariableGen(final int
index of local variable
index
,
final String
its name
name
,
final Type
its type
type
,
final InstructionHandle
from where the instruction is valid (null means from the start)
start
,
final InstructionHandle
until where the instruction is valid (null means to the end)
end
)

Generate a local variable that with index 'index'.

public
LocalVariableGen(final int
index of local variable
index
,
final String
its name
name
,
final Type
its type
type
,
final InstructionHandle
from where the instruction is valid (null means from the start)
start
,
final InstructionHandle
until where the instruction is valid (null means to the end)
end
,
final int
index of local variable prior to any changes to index
origIndex
)

Generates a local variable that with index 'index'.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

public boolean

Returns:

true, if ih is target of this variable
containsTarget
(final InstructionHandle ih)

Implements com.sun.org.apache.bcel.internal.generic.InstructionTargeter.containsTarget.

Tests whether this targeter targets the specified instruction handle.

pack-priv void
dispose()

Clear the references from and to this variable when it's removed.

public boolean
equals(final Object o)

Overrides java.lang.Object.equals.

We consider to local variables to be equal, if the use the same index and are valid in the same range.

public InstructionHandle
public int
public boolean
public LocalVariable
getLocalVariable(final ConstantPoolGen
constant pool
cp
)

Gets LocalVariable object.

public String
public int
public InstructionHandle
public Type
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public void
public void
setIndex(final int index)

public void
setLiveToEnd(final boolean liveToEnd)

public void
public void
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
updateTarget(final InstructionHandle
old target, either start or end
oldIh
,
final InstructionHandle
new target
newIh
)

Implements com.sun.org.apache.bcel.internal.generic.InstructionTargeter.updateTarget.

Replaces the target of this targeter from this old handle to the new handle.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

endback to summary
private InstructionHandle end
indexback to summary
private int index
liveToEndback to summary
private boolean liveToEnd
nameback to summary
private String name
origIndexback to summary
private int origIndex
startback to summary
private InstructionHandle start
typeback to summary
private Type type

Constructor Detail

LocalVariableGenback to summary
public LocalVariableGen(final int index, final String name, final Type type, final InstructionHandle start, final 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:int

index of local variable

name:String

its name

type:Type

its type

start:InstructionHandle

from where the instruction is valid (null means from the start)

end:InstructionHandle

until where the instruction is valid (null means to the end)

LocalVariableGenback to summary
public LocalVariableGen(final int index, final String name, final Type type, final InstructionHandle start, final InstructionHandle end, final int origIndex)

Generates 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:int

index of local variable

name:String

its name

type:Type

its type

start:InstructionHandle

from where the instruction is valid (null means from the start)

end:InstructionHandle

until where the instruction is valid (null means to the end)

origIndex:int

index of local variable prior to any changes to index

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Annotations
@Override
containsTargetback to summary
public boolean containsTarget(final InstructionHandle ih)

Implements com.sun.org.apache.bcel.internal.generic.InstructionTargeter.containsTarget.

Doc from com.sun.org.apache.bcel.internal.generic.InstructionTargeter.containsTarget.

Tests whether this targeter targets the specified instruction handle.

Returns:boolean

true, if ih is target of this variable

Annotations
@Override
disposeback to summary
pack-priv void dispose()

Clear the references from and to this variable when it's removed.

equalsback to summary
public boolean equals(final Object o)

Overrides java.lang.Object.equals.

We consider to local variables to be equal, if the use the same index and are valid in the same range.

Annotations
@Override
getEndback to summary
public InstructionHandle getEnd()
getIndexback to summary
public int getIndex()
getLiveToEndback to summary
public boolean getLiveToEnd()
getLocalVariableback to summary
public LocalVariable getLocalVariable(final ConstantPoolGen cp)

Gets LocalVariable object. This relies on that the instruction list has already been dumped to byte code or that the 'setPositions' methods has been called for the instruction list. Note that due to the conversion from byte code offset to InstructionHandle, it is impossible to tell the difference between a live range that ends BEFORE the last insturction of the method or a live range that ends AFTER the last instruction of the method. Hence the liveToEnd flag to differentiate between these two cases.

Parameters
cp:ConstantPoolGen

constant pool

getNameback to summary
public String getName()

Implements com.sun.org.apache.bcel.internal.generic.NamedAndTyped.getName.

Annotations
@Override
getOrigIndexback to summary
public int getOrigIndex()
getStartback to summary
public InstructionHandle getStart()
getTypeback to summary
public Type getType()

Implements com.sun.org.apache.bcel.internal.generic.NamedAndTyped.getType.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
setEndback to summary
public void setEnd(final InstructionHandle end)
setIndexback to summary
public void setIndex(final int index)
setLiveToEndback to summary
public void setLiveToEnd(final boolean liveToEnd)
setNameback to summary
public void setName(final String name)

Implements com.sun.org.apache.bcel.internal.generic.NamedAndTyped.setName.

Annotations
@Override
setStartback to summary
public void setStart(final InstructionHandle start)
setTypeback to summary
public void setType(final Type type)

Implements com.sun.org.apache.bcel.internal.generic.NamedAndTyped.setType.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
updateTargetback to summary
public void updateTarget(final InstructionHandle oldIh, final InstructionHandle newIh)

Implements com.sun.org.apache.bcel.internal.generic.InstructionTargeter.updateTarget.

Doc from com.sun.org.apache.bcel.internal.generic.InstructionTargeter.updateTarget.

Replaces the target of this targeter from this old handle to the new handle.

Parameters
oldIh:InstructionHandle

old target, either start or end

newIh:InstructionHandle

new target

Annotations
@Override