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