Class ConstantPoolTable

java.lang.Object
serp.bytecode.lowlevel.ConstantPoolTable

public class ConstantPoolTable extends Object
Efficient representation of the constant pool as a table. This class can be used to parse out bits of information from bytecode without instantiating a full BCClass.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private byte[]
     
    private int
     
    private int[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor; supply class bytecode.
    Constructor; supply input stream to bytecode.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    get(int idx)
    Return the given table entry.
    int
    Return the index into the bytecode of the end of the constant pool.
    static int
    getEndIndex(byte[] b)
    Allows static computation of the byte index after the constant pool without caching constant pool information.
    private static int
    parse(byte[] b, int[] table)
    Parse class bytecode, returning end index of pool.
    static int
    readByte(byte[] b, int idx)
    Read a byte value at the given offset into the given bytecode.
    int
    readByte(int idx)
    Read a byte value at the given offset.
    static int
    readInt(byte[] b, int idx)
    Read an int value at the given offset into the given bytecode.
    int
    readInt(int idx)
    Read an int value at the given offset.
    static long
    readLong(byte[] b, int idx)
    Read a long value at the given offset into the given bytecode.
    long
    readLong(int idx)
    Read a long value at the given offset.
    static String
    readString(byte[] b, int idx)
    Read a UTF-8 string value at the given offset into the given bytecode.
    readString(int idx)
    Read a UTF-8 string value at the given offset.
    static int
    readUnsignedShort(byte[] b, int idx)
    Read an unsigned short value at the given offset into the given bytecode.
    int
    Read an unsigned short value at the given offset.
    private static byte[]
    Read the contents of the given stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _bytecode

      private byte[] _bytecode
    • _table

      private int[] _table
    • _idx

      private int _idx
  • Constructor Details

    • ConstantPoolTable

      public ConstantPoolTable(byte[] b)
      Constructor; supply class bytecode.
    • ConstantPoolTable

      public ConstantPoolTable(InputStream in) throws IOException
      Constructor; supply input stream to bytecode.
      Throws:
      IOException
  • Method Details

    • getEndIndex

      public static int getEndIndex(byte[] b)
      Allows static computation of the byte index after the constant pool without caching constant pool information.
    • parse

      private static int parse(byte[] b, int[] table)
      Parse class bytecode, returning end index of pool.
    • readByte

      public static int readByte(byte[] b, int idx)
      Read a byte value at the given offset into the given bytecode.
    • readUnsignedShort

      public static int readUnsignedShort(byte[] b, int idx)
      Read an unsigned short value at the given offset into the given bytecode.
    • readInt

      public static int readInt(byte[] b, int idx)
      Read an int value at the given offset into the given bytecode.
    • readLong

      public static long readLong(byte[] b, int idx)
      Read a long value at the given offset into the given bytecode.
    • readString

      public static String readString(byte[] b, int idx)
      Read a UTF-8 string value at the given offset into the given bytecode.
    • toByteArray

      private static byte[] toByteArray(InputStream in) throws IOException
      Read the contents of the given stream.
      Throws:
      IOException
    • getEndIndex

      public int getEndIndex()
      Return the index into the bytecode of the end of the constant pool.
    • get

      public int get(int idx)
      Return the given table entry.
    • readByte

      public int readByte(int idx)
      Read a byte value at the given offset.
    • readUnsignedShort

      public int readUnsignedShort(int idx)
      Read an unsigned short value at the given offset.
    • readInt

      public int readInt(int idx)
      Read an int value at the given offset.
    • readLong

      public long readLong(int idx)
      Read a long value at the given offset.
    • readString

      public String readString(int idx)
      Read a UTF-8 string value at the given offset.