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  package org.apache.bcel.verifier.structurals;
18  
19  import org.apache.bcel.Const;
20  import org.apache.bcel.Constants;
21  import org.apache.bcel.generic.ObjectType;
22  import org.apache.bcel.generic.ReferenceType;
23  
24  /**
25   * This class represents an uninitialized object type; see The Java Virtual Machine Specification, Second Edition, page
26   * 147: 4.9.4 for more details.
27   */
28  public class UninitializedObjectType extends ReferenceType implements Constants {
29  
30      /** The "initialized" version. */
31      private final ObjectType initialized;
32  
33      /**
34       * Creates a new instance.
35       *
36       * @param objectType uninitialized object type.
37       */
38      public UninitializedObjectType(final ObjectType objectType) {
39          super(Const.T_UNKNOWN, "<UNINITIALIZED OBJECT OF TYPE '" + objectType.getClassName() + "'>");
40          initialized = objectType;
41      }
42  
43      /**
44       * Returns true on equality of this and o. Equality means the ObjectType instances of "initialized" equal one another in
45       * this and the o instance.
46       */
47      @Override
48      public boolean equals(final Object o) {
49          if (!(o instanceof UninitializedObjectType)) {
50              return false;
51          }
52          return initialized.equals(((UninitializedObjectType) o).initialized);
53      }
54  
55      /**
56       * Returns the ObjectType of the same class as the one of the uninitialized object represented by this
57       * UninitializedObjectType instance.
58       *
59       * @return the ObjectType.
60       */
61      public ObjectType getInitialized() {
62          return initialized;
63      }
64  
65      /**
66       * @return a hash code value for the object.
67       */
68      @Override
69      public int hashCode() {
70          return initialized.hashCode();
71      }
72  }