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