    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one
    003 * or more contributor license agreements.  See the NOTICE file
    004 * distributed with this work for additional information
    005 * regarding copyright ownership.  The ASF licenses this file
    006 * to you under the Apache License, Version 2.0 (the
    007 * "License"); you may not use this file except in compliance
    008 * with the License.  You may obtain a copy of the License at
    009 *
    010 *   https://www.apache.org/licenses/LICENSE-2.0
    011 *
    012 * Unless required by applicable law or agreed to in writing,
    013 * software distributed under the License is distributed on an
    014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    015 * KIND, either express or implied.  See the License for the
    016 * specific language governing permissions and limitations
    017 * under the License.
    018 */
    019package org.apache.bcel.classfile;
    020
    021import java.io.DataInput;
    022import java.io.IOException;
    023
    024import org.apache.bcel.Const;
    025
    026/**
    027 * This class represents a constant pool reference to a method.
    028 */
    029public final class ConstantMethodref extends ConstantCP {
    030
    031    /**
    032     * Initialize from another object.
    033     *
    034     * @param c Source to copy.
    035     */
    036    public ConstantMethodref(final ConstantMethodref c) {
    037        super(Const.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex());
    038    }
    039
    040    /**
    041     * Initialize instance from input data.
    042     *
    043     * @param input input stream.
    044     * @throws IOException if an I/O error occurs.
    045     */
    046    ConstantMethodref(final DataInput input) throws IOException {
    047        super(Const.CONSTANT_Methodref, input);
    048    }
    049
    050    /**
    051     * Constructs a ConstantMethodref.
    052     *
    053     * @param classIndex Reference to the class containing the method.
    054     * @param nameAndTypeIndex and the method signature.
    055     */
    056    public ConstantMethodref(final int classIndex, final int nameAndTypeIndex) {
    057        super(Const.CONSTANT_Methodref, classIndex, nameAndTypeIndex);
    058    }
    059
    060    /**
    061     * Called by objects that are traversing the nodes of the tree implicitly defined by the contents of a Java class.
    062     * I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
    063     *.
    064     * @param v Visitor object.
    065     */
    066    @Override
    067    public void accept(final Visitor v) {
    068        v.visitConstantMethodref(this);
    069    }
    070}