View Javadoc
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   */
32  public class UninitializedObjectType extends ReferenceType implements Constants {
33  
34      /** The "initialized" version. */
35      private final ObjectType initialized;
36  
37      /** Creates a new instance. */
38      public UninitializedObjectType(final ObjectType t) {
39          super(Const.T_UNKNOWN, "<UNINITIALIZED OBJECT OF TYPE '"+t.getClassName()+"'>");
40          initialized = t;
41      }
42  
43      /**
44       * Returns the ObjectType of the same class as the one of the uninitialized object
45       * represented by this UninitializedObjectType instance.
46       */
47      public ObjectType getInitialized() {
48          return initialized;
49      }
50  
51      /** @return a hash code value for the object.
52       */
53      @Override
54      public int hashCode() { return initialized.hashCode(); }
55  
56      /**
57       * Returns true on equality of this and o.
58       * Equality means the ObjectType instances of "initialized"
59       * equal one another in this and the o instance.
60       *
61       */
62      @Override
63      public boolean equals(final Object o) {
64          if (! (o instanceof UninitializedObjectType)) {
65              return false;
66          }
67          return initialized.equals(((UninitializedObjectType)o).initialized);
68      }
69  }