001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * https://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.bcel.verifier.structurals; 020 021import org.apache.bcel.Const; 022import org.apache.bcel.Constants; 023import org.apache.bcel.generic.ObjectType; 024import org.apache.bcel.generic.ReferenceType; 025 026/** 027 * This class represents an uninitialized object type; see The Java Virtual Machine Specification, Second Edition, page 028 * 147: 4.9.4 for more details. 029 */ 030public class UninitializedObjectType extends ReferenceType implements Constants { 031 032 /** The "initialized" version. */ 033 private final ObjectType initialized; 034 035 /** 036 * Creates a new instance. 037 * 038 * @param objectType uninitialized object type. 039 */ 040 public UninitializedObjectType(final ObjectType objectType) { 041 super(Const.T_UNKNOWN, "<UNINITIALIZED OBJECT OF TYPE '" + objectType.getClassName() + "'>"); 042 initialized = objectType; 043 } 044 045 /** 046 * Returns true on equality of this and o. Equality means the ObjectType instances of "initialized" equal one another in 047 * this and the o instance. 048 */ 049 @Override 050 public boolean equals(final Object o) { 051 if (!(o instanceof UninitializedObjectType)) { 052 return false; 053 } 054 return initialized.equals(((UninitializedObjectType) o).initialized); 055 } 056 057 /** 058 * Returns the ObjectType of the same class as the one of the uninitialized object represented by this 059 * UninitializedObjectType instance. 060 * 061 * @return the ObjectType. 062 */ 063 public ObjectType getInitialized() { 064 return initialized; 065 } 066 067 /** 068 * @return a hash code value for the object. 069 */ 070 @Override 071 public int hashCode() { 072 return initialized.hashCode(); 073 } 074}