jaxp/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/ReturnaddressType.java
changeset 46174 5611d2529b49
parent 44797 8b3b3b911b8a
equal deleted inserted replaced
46173:5546b5710844 46174:5611d2529b49
    19  * limitations under the License.
    19  * limitations under the License.
    20  */
    20  */
    21 
    21 
    22 package com.sun.org.apache.bcel.internal.generic;
    22 package com.sun.org.apache.bcel.internal.generic;
    23 
    23 
    24 import com.sun.org.apache.bcel.internal.Constants;
    24 import com.sun.org.apache.bcel.internal.Const;
    25 import java.util.Objects;
       
    26 
    25 
    27 /**
    26 /**
    28  * Returnaddress, the type JSR or JSR_W instructions push upon the stack.
    27  * Returnaddress, the type JSR or JSR_W instructions push upon the stack.
    29  *
    28  *
    30  * see vmspec2 3.3.3
    29  * see vmspec2 3.3.3
    31  * @author  <A HREF="http://www.inf.fu-berlin.de/~ehaase">Enver Haase</A>
    30  * @version $Id: ReturnaddressType.java 1749603 2016-06-21 20:50:19Z ggregory $
    32  */
    31  */
    33 public class ReturnaddressType extends Type {
    32 public class ReturnaddressType extends Type {
    34 
    33 
    35   public static final ReturnaddressType NO_TARGET = new ReturnaddressType();
    34     public static final ReturnaddressType NO_TARGET = new ReturnaddressType();
    36   private InstructionHandle returnTarget;
    35     private InstructionHandle returnTarget;
    37 
    36 
    38   /**
       
    39    * A Returnaddress [that doesn't know where to return to].
       
    40    */
       
    41   private ReturnaddressType(){
       
    42     super(Constants.T_ADDRESS, "<return address>");
       
    43   }
       
    44 
    37 
    45   /**
    38     /**
    46    * Creates a ReturnaddressType object with a target.
    39      * A Returnaddress [that doesn't know where to return to].
    47    */
    40      */
    48   public ReturnaddressType(InstructionHandle returnTarget) {
    41     private ReturnaddressType() {
    49     super(Constants.T_ADDRESS, "<return address targeting "+returnTarget+">");
    42         super(Const.T_ADDRESS, "<return address>");
       
    43     }
       
    44 
       
    45 
       
    46     /**
       
    47      * Creates a ReturnaddressType object with a target.
       
    48      */
       
    49     public ReturnaddressType(final InstructionHandle returnTarget) {
       
    50         super(Const.T_ADDRESS, "<return address targeting " + returnTarget + ">");
    50         this.returnTarget = returnTarget;
    51         this.returnTarget = returnTarget;
    51   }
    52     }
    52 
    53 
    53   @Override
       
    54   public int hashCode() {
       
    55       return Objects.hashCode(this.returnTarget);
       
    56   }
       
    57 
    54 
    58   /**
    55     /** @return a hash code value for the object.
    59    * Returns if the two Returnaddresses refer to the same target.
    56      */
    60    */
    57     @Override
    61   @Override
    58     public int hashCode() {
    62   public boolean equals(Object rat){
    59         if (returnTarget == null) {
    63     if(!(rat instanceof ReturnaddressType))
    60             return 0;
    64       return false;
    61         }
       
    62         return returnTarget.hashCode();
       
    63     }
    65 
    64 
    66     return ((ReturnaddressType)rat).returnTarget.equals(this.returnTarget);
       
    67   }
       
    68 
    65 
    69   /**
    66     /**
    70    * @return the target of this ReturnaddressType
    67      * Returns if the two Returnaddresses refer to the same target.
    71    */
    68      */
    72   public InstructionHandle getTarget(){
    69     @Override
    73     return returnTarget;
    70     public boolean equals( final Object rat ) {
    74   }
    71         if (!(rat instanceof ReturnaddressType)) {
       
    72             return false;
       
    73         }
       
    74         final ReturnaddressType that = (ReturnaddressType) rat;
       
    75         if (this.returnTarget == null || that.returnTarget == null) {
       
    76             return that.returnTarget == this.returnTarget;
       
    77         }
       
    78         return that.returnTarget.equals(this.returnTarget);
       
    79     }
       
    80 
       
    81 
       
    82     /**
       
    83      * @return the target of this ReturnaddressType
       
    84      */
       
    85     public InstructionHandle getTarget() {
       
    86         return returnTarget;
       
    87     }
    75 }
    88 }