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