Home | History | Annotate | Download | only in structurals
      1 /*
      2  * Licensed to the Apache Software Foundation (ASF) under one or more
      3  * contributor license agreements.  See the NOTICE file distributed with
      4  * this work for additional information regarding copyright ownership.
      5  * The ASF licenses this file to You under the Apache License, Version 2.0
      6  * (the "License"); you may not use this file except in compliance with
      7  * the License.  You may obtain a copy of the License at
      8  *
      9  *      http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  *
     17  */
     18 package org.apache.bcel.verifier.structurals;
     19 
     20 
     21 import org.apache.bcel.Const;
     22 import org.apache.bcel.Constants;
     23 import org.apache.bcel.generic.ObjectType;
     24 import org.apache.bcel.generic.ReferenceType;
     25 
     26 /**
     27  * This class represents an uninitialized object type; see The Java
     28  * Virtual Machine Specification, Second Edition, page 147: 4.9.4 for
     29  * more details.
     30  *
     31  * @version $Id$
     32  */
     33 public class UninitializedObjectType extends ReferenceType implements Constants {
     34 
     35     /** The "initialized" version. */
     36     private final ObjectType initialized;
     37 
     38     /** Creates a new instance. */
     39     public UninitializedObjectType(final ObjectType t) {
     40         super(Const.T_UNKNOWN, "<UNINITIALIZED OBJECT OF TYPE '"+t.getClassName()+"'>");
     41         initialized = t;
     42     }
     43 
     44     /**
     45      * Returns the ObjectType of the same class as the one of the uninitialized object
     46      * represented by this UninitializedObjectType instance.
     47      */
     48     public ObjectType getInitialized() {
     49         return initialized;
     50     }
     51 
     52     /** @return a hash code value for the object.
     53      */
     54     @Override
     55     public int hashCode() { return initialized.hashCode(); }
     56 
     57     /**
     58      * Returns true on equality of this and o.
     59      * Equality means the ObjectType instances of "initialized"
     60      * equal one another in this and the o instance.
     61      *
     62      */
     63     @Override
     64     public boolean equals(final Object o) {
     65         if (! (o instanceof UninitializedObjectType)) {
     66             return false;
     67         }
     68         return initialized.equals(((UninitializedObjectType)o).initialized);
     69     }
     70 }
     71