Source code

    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 */
    032public class UninitializedObjectType extends ReferenceType implements Constants {
    033
    034    /** The "initialized" version. */
    035    private final ObjectType initialized;
    036
    037    /** Creates a new instance. */
    038    public UninitializedObjectType(final ObjectType t) {
    039        super(Const.T_UNKNOWN, "<UNINITIALIZED OBJECT OF TYPE '"+t.getClassName()+"'>");
    040        initialized = t;
    041    }
    042
    043    /**
    044     * Returns the ObjectType of the same class as the one of the uninitialized object
    045     * represented by this UninitializedObjectType instance.
    046     */
    047    public ObjectType getInitialized() {
    048        return initialized;
    049    }
    050
    051    /** @return a hash code value for the object.
    052     */
    053    @Override
    054    public int hashCode() { return initialized.hashCode(); }
    055
    056    /**
    057     * Returns true on equality of this and o.
    058     * Equality means the ObjectType instances of "initialized"
    059     * equal one another in this and the o instance.
    060     *
    061     */
    062    @Override
    063    public boolean equals(final Object o) {
    064        if (! (o instanceof UninitializedObjectType)) {
    065            return false;
    066        }
    067        return initialized.equals(((UninitializedObjectType)o).initialized);
    068    }
    069}