Package com.ibm.wala.shrike.shrikeCT
Class ConstantPoolParser
- java.lang.Object
-
- com.ibm.wala.shrike.shrikeCT.ConstantPoolParser
-
- All Implemented Interfaces:
ClassConstants
public final class ConstantPoolParser extends java.lang.Object implements ClassConstants
A ConstantPoolParser provides read-only access to the constant pool of a class file.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConstantPoolParser.ReferenceToken
-
Field Summary
-
Fields inherited from interface com.ibm.wala.shrike.shrikeCT.ClassConstants
ACC_ABSTRACT, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_TRANSIENT, ACC_VOLATILE, CONSTANT_Class, CONSTANT_Double, CONSTANT_FieldRef, CONSTANT_Float, CONSTANT_Integer, CONSTANT_InterfaceMethodRef, CONSTANT_InvokeDynamic, CONSTANT_Long, CONSTANT_MethodHandle, CONSTANT_MethodRef, CONSTANT_MethodType, CONSTANT_Module, CONSTANT_NameAndType, CONSTANT_Package, CONSTANT_String, CONSTANT_Utf8, MAGIC, REF_getField, REF_getStatic, REF_invokeInterface, REF_invokeSpecial, REF_invokeStatic, REF_invokeVirtual, REF_newInvokeSpecial, REF_putField, REF_putStatic
-
-
Constructor Summary
Constructors Constructor Description ConstantPoolParser(byte[] bytes, int offset, int itemCount)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetCPClass(int i)doublegetCPDouble(int i)BootstrapMethodsReader.BootstrapMethodgetCPDynBootstrap(int i)java.lang.StringgetCPDynName(int i)java.lang.StringgetCPDynType(int i)floatgetCPFloat(int i)java.lang.StringgetCPHandleClass(int i)bytegetCPHandleKind(int i)java.lang.StringgetCPHandleName(int i)java.lang.StringgetCPHandleType(int i)intgetCPInt(int i)longgetCPLong(int i)java.lang.StringgetCPMethodType(int i)java.lang.StringgetCPNATName(int i)java.lang.StringgetCPNATType(int i)java.lang.StringgetCPRefClass(int i)java.lang.StringgetCPRefName(int i)java.lang.StringgetCPRefType(int i)java.lang.StringgetCPString(int i)java.lang.StringgetCPUtf8(int i)intgetItemCount()bytegetItemType(int i)byte[]getRawBytes()intgetRawOffset()intgetRawSize()static booleanisRef(byte b)Does b represent the tag of a constant pool reference to an (interface) method or field?
-
-
-
Constructor Detail
-
ConstantPoolParser
public ConstantPoolParser(byte[] bytes, int offset, int itemCount) throws InvalidClassFileException- Parameters:
bytes- the raw class file dataoffset- the start of the constant pool dataitemCount- the number of items in the pool- Throws:
InvalidClassFileException
-
-
Method Detail
-
getRawBytes
public byte[] getRawBytes()
- Returns:
- the buffer holding the raw class file data
-
getRawOffset
public int getRawOffset() throws java.lang.IllegalStateException- Returns:
- the offset of the constant pool data in the raw class file buffer
- Throws:
java.lang.IllegalStateException
-
getRawSize
public int getRawSize() throws java.lang.IllegalStateException- Returns:
- the size of the constant pool data in the raw class file buffer
- Throws:
java.lang.IllegalStateException
-
getItemCount
public int getItemCount()
- Returns:
- the number of constant pool items (maximum item index plus one)
-
getItemType
public byte getItemType(int i) throws java.lang.IllegalArgumentException- Returns:
- the type of constant pool item i, or 0 if i is an unused constant pool item
- Throws:
java.lang.IllegalArgumentException
-
getCPClass
public java.lang.String getCPClass(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Returns:
- the name of the Class at constant pool item i, in JVM format (e.g., java/lang/Object)
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPMethodType
public java.lang.String getCPMethodType(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Returns:
- the name of the method at constant pool item i, in JVM format (e.g., java/lang/Object)
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPString
public java.lang.String getCPString(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Returns:
- the String at constant pool item i
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
isRef
public static boolean isRef(byte b)
Does b represent the tag of a constant pool reference to an (interface) method or field?
-
getCPRefClass
public java.lang.String getCPRefClass(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Returns:
- the name of the class part of the FieldRef, MethodRef, or InterfaceMethodRef at constant pool item i
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPRefName
public java.lang.String getCPRefName(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Returns:
- the name part of the FieldRef, MethodRef, or InterfaceMethodRef at constant pool item i
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPRefType
public java.lang.String getCPRefType(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Returns:
- the type part of the FieldRef, MethodRef, or InterfaceMethodRef at constant pool item i, in JVM format (e.g., I, Z, or Ljava/lang/Object;)
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPNATName
public java.lang.String getCPNATName(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Returns:
- the name part of the NameAndType at constant pool item i
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPNATType
public java.lang.String getCPNATType(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Returns:
- the type part of the NameAndType at constant pool item i, in JVM format (e.g., I, Z, or Ljava/lang/Object;)
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPHandleName
public java.lang.String getCPHandleName(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Returns:
- the name part of the MethodHandle at constant pool item i, in JVM format (e.g., I, Z, or Ljava/lang/Object;)
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPHandleType
public java.lang.String getCPHandleType(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Returns:
- the name part of the MethodHandle at constant pool item i, in JVM format (e.g., I, Z, or Ljava/lang/Object;)
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPHandleClass
public java.lang.String getCPHandleClass(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Returns:
- the name part of the MethodHandle at constant pool item i, in JVM format (e.g., I, Z, or Ljava/lang/Object;)
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPHandleKind
public byte getCPHandleKind(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Returns:
- the type of the MethodHandle at constant pool item i
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPInt
public int getCPInt(int i) throws java.lang.IllegalArgumentException- Returns:
- the value of the Integer at constant pool item i
- Throws:
java.lang.IllegalArgumentException
-
getCPFloat
public float getCPFloat(int i) throws java.lang.IllegalArgumentException- Returns:
- the value of the Float at constant pool item i
- Throws:
java.lang.IllegalArgumentException
-
getCPLong
public long getCPLong(int i) throws java.lang.IllegalArgumentException- Returns:
- the value of the Long at constant pool item i
- Throws:
java.lang.IllegalArgumentException
-
getCPDouble
public double getCPDouble(int i) throws java.lang.IllegalArgumentException- Returns:
- the value of the Double at constant pool item i
- Throws:
java.lang.IllegalArgumentException
-
getCPDynBootstrap
public BootstrapMethodsReader.BootstrapMethod getCPDynBootstrap(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException
- Returns:
- the BootstrapMethodTable index of the bootstrap method for this invokedynamic
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPDynName
public java.lang.String getCPDynName(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPDynType
public java.lang.String getCPDynType(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
getCPUtf8
public java.lang.String getCPUtf8(int i) throws InvalidClassFileException, java.lang.IllegalArgumentException- Returns:
- the value of the Utf8 string at constant pool item i
- Throws:
InvalidClassFileExceptionjava.lang.IllegalArgumentException
-
-