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 class
ConstantPoolParser.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 String
getCPClass(int i)
double
getCPDouble(int i)
BootstrapMethodsReader.BootstrapMethod
getCPDynBootstrap(int i)
String
getCPDynName(int i)
String
getCPDynType(int i)
float
getCPFloat(int i)
String
getCPHandleClass(int i)
byte
getCPHandleKind(int i)
String
getCPHandleName(int i)
String
getCPHandleType(int i)
int
getCPInt(int i)
long
getCPLong(int i)
String
getCPMethodType(int i)
String
getCPNATName(int i)
String
getCPNATType(int i)
String
getCPRefClass(int i)
String
getCPRefName(int i)
String
getCPRefType(int i)
String
getCPString(int i)
String
getCPUtf8(int i)
int
getItemCount()
byte
getItemType(int i)
byte[]
getRawBytes()
int
getRawOffset()
int
getRawSize()
static boolean
isRef(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:
InvalidClassFileException
IllegalArgumentException
-
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:
InvalidClassFileException
IllegalArgumentException
-
getCPString
public String getCPString(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the String at constant pool item i
- Throws:
InvalidClassFileException
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 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:
InvalidClassFileException
IllegalArgumentException
-
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:
InvalidClassFileException
IllegalArgumentException
-
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:
InvalidClassFileException
IllegalArgumentException
-
getCPNATName
public String getCPNATName(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the name part of the NameAndType at constant pool item i
- Throws:
InvalidClassFileException
IllegalArgumentException
-
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:
InvalidClassFileException
IllegalArgumentException
-
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:
InvalidClassFileException
IllegalArgumentException
-
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:
InvalidClassFileException
IllegalArgumentException
-
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:
InvalidClassFileException
IllegalArgumentException
-
getCPHandleKind
public byte getCPHandleKind(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the type of the MethodHandle at constant pool item i
- Throws:
InvalidClassFileException
IllegalArgumentException
-
getCPInt
public int getCPInt(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the value of the Integer at constant pool item i
- Throws:
InvalidClassFileException
IllegalArgumentException
-
getCPFloat
public float getCPFloat(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the value of the Float at constant pool item i
- Throws:
InvalidClassFileException
IllegalArgumentException
-
getCPLong
public long getCPLong(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the value of the Long at constant pool item i
- Throws:
InvalidClassFileException
IllegalArgumentException
-
getCPDouble
public double getCPDouble(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the value of the Double at constant pool item i
- Throws:
InvalidClassFileException
IllegalArgumentException
-
getCPDynBootstrap
public BootstrapMethodsReader.BootstrapMethod getCPDynBootstrap(int i) throws InvalidClassFileException, IllegalArgumentException
- Returns:
- the BootstrapMethodTable index of the bootstrap method for this invokedynamic
- Throws:
InvalidClassFileException
IllegalArgumentException
-
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:
InvalidClassFileException
IllegalArgumentException
-
-