Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/reflect/ConstantPool.java
38829 views
/*1* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.reflect;2627import java.lang.reflect.*;2829/** Provides reflective access to the constant pools of classes.30Currently this is needed to provide reflective access to annotations31but may be used by other internal subsystems in the future. */3233public class ConstantPool {34// Number of entries in this constant pool (= maximum valid constant pool index)35public int getSize() { return getSize0 (constantPoolOop); }36public Class<?> getClassAt (int index) { return getClassAt0 (constantPoolOop, index); }37public Class<?> getClassAtIfLoaded (int index) { return getClassAtIfLoaded0 (constantPoolOop, index); }38// Returns either a Method or Constructor.39// Static initializers are returned as Method objects.40public Member getMethodAt (int index) { return getMethodAt0 (constantPoolOop, index); }41public Member getMethodAtIfLoaded(int index) { return getMethodAtIfLoaded0(constantPoolOop, index); }42public Field getFieldAt (int index) { return getFieldAt0 (constantPoolOop, index); }43public Field getFieldAtIfLoaded (int index) { return getFieldAtIfLoaded0 (constantPoolOop, index); }44// Fetches the class name, member (field, method or interface45// method) name, and type descriptor as an array of three Strings46public String[] getMemberRefInfoAt (int index) { return getMemberRefInfoAt0 (constantPoolOop, index); }47public int getIntAt (int index) { return getIntAt0 (constantPoolOop, index); }48public long getLongAt (int index) { return getLongAt0 (constantPoolOop, index); }49public float getFloatAt (int index) { return getFloatAt0 (constantPoolOop, index); }50public double getDoubleAt (int index) { return getDoubleAt0 (constantPoolOop, index); }51public String getStringAt (int index) { return getStringAt0 (constantPoolOop, index); }52public String getUTF8At (int index) { return getUTF8At0 (constantPoolOop, index); }5354//---------------------------------------------------------------------------55// Internals only below this point56//5758static {59Reflection.registerFieldsToFilter(ConstantPool.class, new String[] { "constantPoolOop" });60}6162// HotSpot-internal constant pool object (set by the VM, name known to the VM)63private Object constantPoolOop;6465private native int getSize0 (Object constantPoolOop);66private native Class<?> getClassAt0 (Object constantPoolOop, int index);67private native Class<?> getClassAtIfLoaded0 (Object constantPoolOop, int index);68private native Member getMethodAt0 (Object constantPoolOop, int index);69private native Member getMethodAtIfLoaded0(Object constantPoolOop, int index);70private native Field getFieldAt0 (Object constantPoolOop, int index);71private native Field getFieldAtIfLoaded0 (Object constantPoolOop, int index);72private native String[] getMemberRefInfoAt0 (Object constantPoolOop, int index);73private native int getIntAt0 (Object constantPoolOop, int index);74private native long getLongAt0 (Object constantPoolOop, int index);75private native float getFloatAt0 (Object constantPoolOop, int index);76private native double getDoubleAt0 (Object constantPoolOop, int index);77private native String getStringAt0 (Object constantPoolOop, int index);78private native String getUTF8At0 (Object constantPoolOop, int index);79}808182