< prev index next >
src/java.base/share/classes/sun/reflect/ConstantPool.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 34,59 ****
--- 34,113 ----
public class ConstantPool {
// Number of entries in this constant pool (= maximum valid constant pool index)
public int getSize() { return getSize0 (constantPoolOop); }
public Class<?> getClassAt (int index) { return getClassAt0 (constantPoolOop, index); }
public Class<?> getClassAtIfLoaded (int index) { return getClassAtIfLoaded0 (constantPoolOop, index); }
+ // Returns a class reference index for a method or a field.
+ public int getClassRefIndexAt(int index) {
+ return getClassRefIndexAt0(constantPoolOop, index);
+ }
// Returns either a Method or Constructor.
// Static initializers are returned as Method objects.
public Member getMethodAt (int index) { return getMethodAt0 (constantPoolOop, index); }
public Member getMethodAtIfLoaded(int index) { return getMethodAtIfLoaded0(constantPoolOop, index); }
public Field getFieldAt (int index) { return getFieldAt0 (constantPoolOop, index); }
public Field getFieldAtIfLoaded (int index) { return getFieldAtIfLoaded0 (constantPoolOop, index); }
// Fetches the class name, member (field, method or interface
// method) name, and type descriptor as an array of three Strings
public String[] getMemberRefInfoAt (int index) { return getMemberRefInfoAt0 (constantPoolOop, index); }
+ // Returns a name and type reference index for a method, a field or an invokedynamic.
+ public int getNameAndTypeRefIndexAt(int index) {
+ return getNameAndTypeRefIndexAt0(constantPoolOop, index);
+ }
+ // Fetches the name and type from name_and_type index as an array of two Strings
+ public String[] getNameAndTypeRefInfoAt(int index) {
+ return getNameAndTypeRefInfoAt0(constantPoolOop, index);
+ }
public int getIntAt (int index) { return getIntAt0 (constantPoolOop, index); }
public long getLongAt (int index) { return getLongAt0 (constantPoolOop, index); }
public float getFloatAt (int index) { return getFloatAt0 (constantPoolOop, index); }
public double getDoubleAt (int index) { return getDoubleAt0 (constantPoolOop, index); }
public String getStringAt (int index) { return getStringAt0 (constantPoolOop, index); }
public String getUTF8At (int index) { return getUTF8At0 (constantPoolOop, index); }
+ public Tag getTagAt(int index) {
+ return Tag.valueOf(getTagAt0(constantPoolOop, index));
+ }
+ public static enum Tag {
+ UTF8,
+ INTEGER,
+ FLOAT,
+ LONG,
+ DOUBLE,
+ CLASS,
+ STRING,
+ FIELDREF,
+ METHODREF,
+ INTERFACEMETHODREF,
+ NAMEANDTYPE,
+ METHODHANDLE,
+ METHODTYPE,
+ INVOKEDYNAMIC,
+ INVALID;
+
+ private static Tag valueOf(byte v) {
+ switch (v) {
+ case 0: return INVALID;
+ case 1: return UTF8;
+ case 3: return INTEGER;
+ case 4: return FLOAT;
+ case 5: return LONG;
+ case 6: return DOUBLE;
+ case 7: return CLASS;
+ case 8: return STRING;
+ case 9: return FIELDREF;
+ case 10: return METHODREF;
+ case 11: return INTERFACEMETHODREF;
+ case 12: return NAMEANDTYPE;
+ case 15: return METHODHANDLE;
+ case 16: return METHODTYPE;
+ case 18: return INVOKEDYNAMIC;
+ default:
+ throw new IllegalArgumentException("Unknown constant pool tag " + v);
+ }
+ }
+ }
//---------------------------------------------------------------------------
// Internals only below this point
//
static {
*** 64,80 ****
--- 118,138 ----
private Object constantPoolOop;
private native int getSize0 (Object constantPoolOop);
private native Class<?> getClassAt0 (Object constantPoolOop, int index);
private native Class<?> getClassAtIfLoaded0 (Object constantPoolOop, int index);
+ private native int getClassRefIndexAt0 (Object constantPoolOop, int index);
private native Member getMethodAt0 (Object constantPoolOop, int index);
private native Member getMethodAtIfLoaded0(Object constantPoolOop, int index);
private native Field getFieldAt0 (Object constantPoolOop, int index);
private native Field getFieldAtIfLoaded0 (Object constantPoolOop, int index);
private native String[] getMemberRefInfoAt0 (Object constantPoolOop, int index);
+ private native int getNameAndTypeRefIndexAt0(Object constantPoolOop, int index);
+ private native String[] getNameAndTypeRefInfoAt0(Object constantPoolOop, int index);
private native int getIntAt0 (Object constantPoolOop, int index);
private native long getLongAt0 (Object constantPoolOop, int index);
private native float getFloatAt0 (Object constantPoolOop, int index);
private native double getDoubleAt0 (Object constantPoolOop, int index);
private native String getStringAt0 (Object constantPoolOop, int index);
private native String getUTF8At0 (Object constantPoolOop, int index);
+ private native byte getTagAt0 (Object constantPoolOop, int index);
}
< prev index next >