Package com.ibm.wala.shrikeCT
Class ConstantPoolParser
- java.lang.Object
-
- com.ibm.wala.shrikeCT.ConstantPoolParser
-
- All Implemented Interfaces:
ClassConstants
public final class ConstantPoolParser extends 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.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_NameAndType, 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 StringgetCPClass(int i)doublegetCPDouble(int i)BootstrapMethodsReader.BootstrapMethodgetCPDynBootstrap(int i)StringgetCPDynName(int i)StringgetCPDynType(int i)floatgetCPFloat(int i)StringgetCPHandleClass(int i)bytegetCPHandleKind(int i)StringgetCPHandleName(int i)StringgetCPHandleType(int i)intgetCPInt(int i)longgetCPLong(int i)StringgetCPMethodType(int i)StringgetCPNATName(int i)StringgetCPNATType(int i)StringgetCPRefClass(int i)StringgetCPRefName(int i)StringgetCPRefType(int i)StringgetCPString(int i)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 poolclassReader-- Throws:
InvalidClassFileException
-
-
Method Detail
-
getRawBytes
public byte[] getRawBytes()
- Returns:
- the buffer holding the raw class file data
-
getRawOffset
public int getRawOffset() throws IllegalStateException- Returns:
- the offset of the constant pool data in the raw class file buffer
- Throws:
IllegalStateException
-
getRawSize
public int getRawSize() throws IllegalStateException- Returns:
- the size of the constant pool data in the raw class file buffer
- Throws:
IllegalStateException
-
getItemCount
public int getItemCount()
- Returns:
- the number of constant pool items (maximum item index plus one)
-
getItemType
public byte getItemType(int i) throws IllegalArgumentException- Returns:
- the type of constant pool item i, or 0 if i is an unused constant pool item
- Throws:
IllegalArgumentException
-
getCPClass
public String getCPClass(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the name of the Class at constant pool item i, in JVM format (e.g., java/lang/Object)
- Throws:
InvalidClassFileExceptionIllegalArgumentException
-
getCPMethodType
public String getCPMethodType(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the name of the method at constant pool item i, in JVM format (e.g., java/lang/Object)
- Throws:
InvalidClassFileExceptionIllegalArgumentException
-
getCPString
public String getCPString(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the String at constant pool item i
- Throws:
InvalidClassFileExceptionIllegalArgumentException
-
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 String getCPRefClass(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the name of the class part of the FieldRef, MethodRef, or InterfaceMethodRef at constant pool item i
- Throws:
InvalidClassFileExceptionIllegalArgumentException
-
getCPRefName
public String getCPRefName(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the name part of the FieldRef, MethodRef, or InterfaceMethodRef at constant pool item i
- Throws:
InvalidClassFileExceptionIllegalArgumentException
-
getCPRefType
public String getCPRefType(int i) throws InvalidClassFileException, 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:
InvalidClassFileExceptionIllegalArgumentException
-
getCPNATName
public String getCPNATName(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the name part of the NameAndType at constant pool item i
- Throws:
InvalidClassFileExceptionIllegalArgumentException
-
getCPNATType
public String getCPNATType(int i) throws InvalidClassFileException, 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:
InvalidClassFileExceptionIllegalArgumentException
-
getCPHandleName
public String getCPHandleName(int i) throws InvalidClassFileException, 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:
InvalidClassFileExceptionIllegalArgumentException
-
getCPHandleType
public String getCPHandleType(int i) throws InvalidClassFileException, 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:
InvalidClassFileExceptionIllegalArgumentException
-
getCPHandleClass
public String getCPHandleClass(int i) throws InvalidClassFileException, 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:
InvalidClassFileExceptionIllegalArgumentException
-
getCPHandleKind
public byte getCPHandleKind(int i) throws InvalidClassFileException, IllegalArgumentException- Returns:
- the type of the MethodHandle at constant pool item i
- Throws:
InvalidClassFileExceptionIllegalArgumentException
-
getCPInt
public int getCPInt(int i) throws InvalidClassFileException, IllegalArgumentException- Returns:
- the value of the Integer at constant pool item i
- Throws:
InvalidClassFileExceptionIllegalArgumentException
-
getCPFloat
public float getCPFloat(int i) throws InvalidClassFileException, IllegalArgumentException- Returns:
- the value of the Float at constant pool item i
- Throws:
InvalidClassFileExceptionIllegalArgumentException
-
getCPLong
public long getCPLong(int i) throws InvalidClassFileException, IllegalArgumentException- Returns:
- the value of the Long at constant pool item i
- Throws:
InvalidClassFileExceptionIllegalArgumentException
-
getCPDouble
public double getCPDouble(int i) throws InvalidClassFileException, IllegalArgumentException- Returns:
- the value of the Double at constant pool item i
- Throws:
InvalidClassFileExceptionIllegalArgumentException
-
getCPDynBootstrap
public BootstrapMethodsReader.BootstrapMethod getCPDynBootstrap(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the BootstrapMethodTable index of the bootstrap method for this invokedynamic
- Throws:
InvalidClassFileExceptionIllegalArgumentException
-
getCPDynName
public String getCPDynName(int i) throws InvalidClassFileException, IllegalArgumentException
-
getCPDynType
public String getCPDynType(int i) throws InvalidClassFileException, IllegalArgumentException
-
getCPUtf8
public String getCPUtf8(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the value of the Utf8 string at constant pool item i
- Throws:
InvalidClassFileExceptionIllegalArgumentException
-
-