1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Licensed to the Apache Software Foundation (ASF) under one or more 7 * contributor license agreements. See the NOTICE file distributed with 8 * this work for additional information regarding copyright ownership. 9 * The ASF licenses this file to You under the Apache License, Version 2.0 10 * (the "License"); you may not use this file except in compliance with 11 * the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 */ 21 22 package com.sun.org.apache.bcel.internal.classfile; 23 24 import java.io.DataInput; 25 import java.io.IOException; 26 27 import com.sun.org.apache.bcel.internal.Const; 28 29 /** 30 * This class represents a constant pool reference to a field. 31 * 32 */ 33 public final class ConstantFieldref extends ConstantCP { 34 35 /** 36 * Initialize from another object. 37 */ 38 public ConstantFieldref(final ConstantFieldref c) { 39 super(Const.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex()); 40 } 41 42 43 /** 44 * Initialize instance from input data. 45 * 46 * @param input input stream 47 * @throws IOException 48 */ 49 ConstantFieldref(final DataInput input) throws IOException { 50 super(Const.CONSTANT_Fieldref, input); 51 } 52 53 54 /** 55 * @param class_index Reference to the class containing the Field 56 * @param name_and_type_index and the Field signature 57 */ 58 public ConstantFieldref(final int class_index, final int name_and_type_index) { 59 super(Const.CONSTANT_Fieldref, 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 Fields, 66 * fields, attributes, etc. spawns a tree of objects. 67 * 68 * @param v Visitor object 69 */ 70 @Override 71 public void accept( final Visitor v ) { 72 v.visitConstantFieldref(this); 73 } 74 }