1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18 package org.apache.bcel.classfile;
19
20 import java.io.DataInputStream;
21 import java.io.IOException;
22 import org.apache.bcel.Constants;
23
24 /**
25 * This class represents a constant pool reference to a method.
26 *
27 * @version $Id: ConstantMethodref.java 1152072 2011-07-29 01:54:05Z dbrosius $
28 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29 */
30 public final class ConstantMethodref extends ConstantCP {
31
32 private static final long serialVersionUID = -864296320352750967L;
33
34
35 /**
36 * Initialize from another object.
37 */
38 public ConstantMethodref(ConstantMethodref c) {
39 super(Constants.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex());
40 }
41
42
43 /**
44 * Initialize instance from file data.
45 *
46 * @param file input stream
47 * @throws IOException
48 */
49 ConstantMethodref(DataInputStream file) throws IOException {
50 super(Constants.CONSTANT_Methodref, file);
51 }
52
53
54 /**
55 * @param class_index Reference to the class containing the method
56 * @param name_and_type_index and the method signature
57 */
58 public ConstantMethodref(int class_index, int name_and_type_index) {
59 super(Constants.CONSTANT_Methodref, class_index, name_and_type_index);
60 }
61
62
63 /**
64 * Called by objects that are traversing the nodes of the tree implicitely
65 * defined by the contents of a Java class. I.e., the hierarchy of methods,
66 * fields, attributes, etc. spawns a tree of objects.
67 *
68 * @param v Visitor object
69 */
70 @Override
71 public void accept( Visitor v ) {
72 v.visitConstantMethodref(this);
73 }
74 }