Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Class LocalVariableGen  view LocalVariableGen download

  extended byorg.apache.bcel.generic.LocalVariableGen
All Implemented Interfaces:
java.lang.Cloneable, InstructionTargeter, NamedAndTyped,

public class LocalVariableGen
extends java.lang.Object
implements InstructionTargeter, NamedAndTyped, java.lang.Cloneable,

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.

$Id: 386056 2006-03-15 11:31:56Z tcurdt $

Field Summary
private  InstructionHandle end
private  int index
private  java.lang.String name
private  InstructionHandle start
private  Type type
Constructor Summary
LocalVariableGen(int index, java.lang.String name, Type type, InstructionHandle start, InstructionHandle end)
          Generate a local variable that with index `index'.
Method Summary
 java.lang.Object clone()
          This method may be called to create a new copy of the Object.
 boolean containsTarget(InstructionHandle ih)
 boolean equals(java.lang.Object o)
          We consider to local variables to be equal, if the use the same index and are valid in the same range.
 InstructionHandle getEnd()
 int getIndex()
 org.apache.bcel.classfile.LocalVariable getLocalVariable(ConstantPoolGen cp)
          Get LocalVariable object.
 java.lang.String getName()
 InstructionHandle getStart()
 Type getType()
 int hashCode()
          Get a value that represents this Object, as uniquely as possible within the confines of an int.
 void setEnd(InstructionHandle end)
 void setIndex(int index)
 void setName(java.lang.String name)
 void setStart(InstructionHandle start)
 void setType(Type type)
 java.lang.String toString()
          Convert this Object to a human-readable String.
 void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih)
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait

Field Detail


private int index


private java.lang.String name


private Type type


private InstructionHandle start


private InstructionHandle end
Constructor Detail


public LocalVariableGen(int index,
                        java.lang.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.

Method Detail


public org.apache.bcel.classfile.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.


public void setIndex(int index)


public int getIndex()


public void setName(java.lang.String name)
Specified by:
setName in interface NamedAndTyped


public java.lang.String getName()
Specified by:
getName in interface NamedAndTyped


public void setType(Type type)
Specified by:
setType in interface NamedAndTyped


public Type getType()
Specified by:
getType in interface NamedAndTyped


public InstructionHandle getStart()


public InstructionHandle getEnd()


public void setStart(InstructionHandle start)


public void setEnd(InstructionHandle end)


public void updateTarget(InstructionHandle old_ih,
                         InstructionHandle new_ih)
Specified by:
updateTarget in interface InstructionTargeter


public boolean containsTarget(InstructionHandle ih)
Specified by:
containsTarget in interface InstructionTargeter


public int hashCode()
Description copied from class: java.lang.Object
Get a value that represents this Object, as uniquely as possible within the confines of an int.

There are some requirements on this method which subclasses must follow:

  • Semantic equality implies identical hashcodes. In other words, if a.equals(b) is true, then a.hashCode() == b.hashCode() must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal.
  • It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.

Notice that since hashCode is used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.

The default implementation returns System.identityHashCode(this)


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


public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


public java.lang.Object clone()
Description copied from class: java.lang.Object
This method may be called to create a new copy of the Object. The typical behavior is as follows:
  • o == o.clone() is false
  • o.getClass() == o.clone().getClass() is true
  • o.equals(o) is true

However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>Object.equals(Object) 55 .

If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.

Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.

All array types implement Cloneable, and override this method as follows (it should never fail):

 public Object clone()
   catch (CloneNotSupportedException e)
       throw new InternalError(e.getMessage());