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