jaxp/src/com/sun/org/apache/bcel/internal/generic/LocalVariableGen.java

Print this page

        

@@ -58,10 +58,11 @@
  * <http://www.apache.org/>.
  */
 
 import com.sun.org.apache.bcel.internal.Constants;
 import com.sun.org.apache.bcel.internal.classfile.*;
+import java.util.Objects;
 
 /**
  * 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

@@ -131,13 +132,17 @@
                              signature_index, index, cp.getConstantPool());
   }
 
   public void        setIndex(int index)           { this.index = index; }
   public int         getIndex()                   { return index; }
+  @Override
   public void        setName(String name)        { this.name = name; }
+  @Override
   public String      getName()                   { return name; }
+  @Override
   public void        setType(Type type)          { this.type = type; }
+  @Override
   public Type        getType()                   { return type; }
 
   public InstructionHandle getStart()                  { return start; }
   public InstructionHandle getEnd()                    { return end; }
 

@@ -153,10 +158,11 @@
 
   /**
    * @param old_ih old target, either start or end
    * @param new_ih new target
    */
+  @Override
   public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
     boolean targeted = false;
 
     if(start == old_ih) {
       targeted = true;

@@ -174,30 +180,43 @@
   }
 
   /**
    * @return true, if ih is target of this variable
    */
+  @Override
   public boolean containsTarget(InstructionHandle ih) {
     return (start == ih) || (end == ih);
   }
 
   /**
    * We consider to local variables to be equal, if the use the same index and
    * are valid in the same range.
    */
+  @Override
   public boolean equals(Object o) {
     if(!(o instanceof LocalVariableGen))
       return false;
 
     LocalVariableGen l = (LocalVariableGen)o;
     return (l.index == index) && (l.start == start) && (l.end == end);
   }
 
+  @Override
+  public int hashCode() {
+    int hash = 7;
+    hash = 59 * hash + this.index;
+    hash = 59 * hash + Objects.hashCode(this.start);
+    hash = 59 * hash + Objects.hashCode(this.end);
+    return hash;
+  }
+
+  @Override
   public String toString() {
     return "LocalVariableGen(" + name +  ", " + type +  ", " + start + ", " + end + ")";
   }
 
+  @Override
   public Object clone() {
     try {
       return super.clone();
     } catch(CloneNotSupportedException e) {
       System.err.println(e);