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 020import org.apache.bcel.Const; 021import org.apache.bcel.Constants; 022import org.apache.bcel.generic.ObjectType; 023import org.apache.bcel.generic.ReferenceType; 024 025/** 026 * This class represents an uninitialized object type; see The Java Virtual Machine Specification, Second Edition, page 027 * 147: 4.9.4 for more details. 028 * 029 */ 030public class UninitializedObjectType extends ReferenceType implements Constants { 031 032 /** The "initialized" version. */ 033 private final ObjectType initialized; 034 035 /** Creates a new instance. */ 036 public UninitializedObjectType(final ObjectType t) { 037 super(Const.T_UNKNOWN, "<UNINITIALIZED OBJECT OF TYPE '" + t.getClassName() + "'>"); 038 initialized = t; 039 } 040 041 /** 042 * Returns true on equality of this and o. Equality means the ObjectType instances of "initialized" equal one another in 043 * this and the o instance. 044 * 045 */ 046 @Override 047 public boolean equals(final Object o) { 048 if (!(o instanceof UninitializedObjectType)) { 049 return false; 050 } 051 return initialized.equals(((UninitializedObjectType) o).initialized); 052 } 053 054 /** 055 * Returns the ObjectType of the same class as the one of the uninitialized object represented by this 056 * UninitializedObjectType instance. 057 */ 058 public ObjectType getInitialized() { 059 return initialized; 060 } 061 062 /** 063 * @return a hash code value for the object. 064 */ 065 @Override 066 public int hashCode() { 067 return initialized.hashCode(); 068 } 069}