Class BytecodeReader

java.lang.Object
mockit.asm.util.BytecodeReader
Direct Known Subclasses:
AnnotatedReader, AnnotationReader

public class BytecodeReader extends Object
  • Field Details

    • code

      @NonNull public final byte[] code
      The class to be parsed. The content of this array must not be modified.
    • items

      @NonNull public final int[] items
      The start index of each constant pool item in code, plus one. The one byte offset skips the constant pool item tag that indicates its type.
    • codeIndex

      public @NonNegative int codeIndex
      The next index at code to be read.
  • Constructor Details

    • BytecodeReader

      protected BytecodeReader(@NonNull byte[] code)
    • BytecodeReader

      protected BytecodeReader(@NonNull BytecodeReader another)
  • Method Details

    • readUnsignedByte

      public final @NonNegative int readUnsignedByte()
      Reads an unsigned byte value in code, incrementing codeIndex by 1.
      Returns:
      the int
    • readUnsignedByte

      protected final @NonNegative int readUnsignedByte(@NonNegative int u1CodeIndex)
      Reads an unsigned byte value in code.
      Parameters:
      u1CodeIndex - the start index of the value to be read in code
      Returns:
      the int
    • readSignedByte

      public final int readSignedByte()
      Reads a signed byte value in code, incrementing codeIndex by 1.
      Returns:
      the int
    • readChar

      protected final char readChar(@NonNegative int s4CodeIndex)
    • readBoolean

      protected final boolean readBoolean(@NonNegative int s4CodeIndex)
    • readUnsignedShort

      public final @NonNegative int readUnsignedShort()
      Reads an unsigned short value in code, incrementing codeIndex by 2.
      Returns:
      the int
    • readUnsignedShort

      protected final @NonNegative int readUnsignedShort(@NonNegative int u2CodeIndex)
      Reads an unsigned short value in code.
      Parameters:
      u2CodeIndex - the start index of the value to be read in code
      Returns:
      the int
    • readShort

      protected final short readShort()
      Reads a signed short value in code, incrementing codeIndex by 2.
      Returns:
      the short
    • readShort

      protected final short readShort(@NonNegative int u2CodeIndex)
      Reads a signed short value in code.
      Parameters:
      u2CodeIndex - the start index of the value to be read in code
      Returns:
      the short
    • readInt

      public final int readInt()
      Reads a signed int value in code, incrementing codeIndex by 4.
      Returns:
      the int
    • readInt

      protected final int readInt(@NonNegative int s4CodeIndex)
      Reads a signed int value in code.
      Parameters:
      s4CodeIndex - the start index of the value to be read in code
      Returns:
      the int
    • readLong

      public final long readLong()
      Reads a signed long value in code, incrementing codeIndex by 8.
      Returns:
      the long
    • readLong

      protected final long readLong(@NonNegative int s8CodeIndex)
      Reads a signed long value in code.
      Parameters:
      s8CodeIndex - the start index of the value to be read in code
      Returns:
      the long
    • readDouble

      public final double readDouble()
    • readDouble

      protected final double readDouble(@NonNegative int s8CodeIndex)
    • readFloat

      public final float readFloat()
    • readFloat

      protected final float readFloat(@NonNegative int s4CodeIndex)
    • readUTF8

      @Nullable protected final String readUTF8()
      Reads an UTF8 string constant pool item in code, incrementing codeIndex by 2.
      Returns:
      the String corresponding to the UTF8 item, or null if codeIndex points to an item whose value is zero
    • readUTF8

      @Nullable protected final String readUTF8(@NonNegative int u2CodeIndex)
      Reads an UTF8 string constant pool item in code.
      Parameters:
      u2CodeIndex - the index of an unsigned short value in code, whose value is the index of an UTF8 constant pool item
      Returns:
      the String corresponding to the UTF8 item, or null if index is zero or points to an item whose value is zero
    • readNonnullUTF8

      @NonNull public final String readNonnullUTF8()
      Reads the index of an UTF8 item in code, incrementing codeIndex by 2.
      Returns:
      the UTF8 string found in strings at that index
    • readNonnullUTF8

      @NonNull public final String readNonnullUTF8(@NonNegative int u2CodeIndex)
      Reads the index of an UTF8 item in code.
      Parameters:
      u2CodeIndex - the u 2 code index
      Returns:
      the UTF8 string found in strings at that index
    • readString

      @NonNull public final String readString(@NonNegative int itemIndex)
      Reads a string in strings at the given index.
      Parameters:
      itemIndex - the item index
      Returns:
      the string
    • readConstItem

      @NonNull public final Object readConstItem()
      Reads the index of a constant item in code, incrementing codeIndex by 2.
      Returns:
      the UTF8 string found in strings at that index
    • readConstItem

      @NonNull protected final Object readConstItem(@NonNegative int u2CodeIndex)
    • readConst

      @NonNull protected final Object readConst(@NonNegative int itemIndex)
      Reads a numeric or string constant pool item in code.
      Parameters:
      itemIndex - the index of a constant pool item
      Returns:
      the Integer, Float, Long, Double, String, JavaType or MethodHandle corresponding to the given constant pool item
    • readMethodHandle

      @NonNull public final MethodHandle readMethodHandle()
    • readMethodHandleItem

      @NonNull protected final MethodHandle readMethodHandleItem(@NonNegative int bsmCodeIndex)
    • readClass

      @Nullable protected final String readClass()
      Reads the class name from the constant pool, incrementing codeIndex by 2.
      Returns:
      the string
    • readNonnullClass

      @NonNull public final String readNonnullClass()
      Reads a class descriptor in code, incrementing codeIndex by 2.
      Returns:
      the string
    • readNonnullClass

      @NonNull public final String readNonnullClass(@NonNegative int u2CodeIndex)
    • readItem

      public final @NonNegative int readItem()
      Reads an item index in code, incrementing codeIndex by 2.
      Returns:
      the item at that index in items
    • readItem

      public final @NonNegative int readItem(@NonNegative int u2CodeIndex)