Class BytecodeReader

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

public class BytecodeReader extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final byte[]
    The class to be parsed.
    @org.checkerframework.checker.index.qual.NonNegative int
    The next index at code to be read.
    final int[]
    The start index of each constant pool item in code, plus one.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    BytecodeReader(byte[] code)
     
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final boolean
    readBoolean(@org.checkerframework.checker.index.qual.NonNegative int s4CodeIndex)
     
    protected final char
    readChar(@org.checkerframework.checker.index.qual.NonNegative int s4CodeIndex)
     
    protected final String
    Reads the class name from the constant pool, incrementing codeIndex by 2.
    protected final Object
    readConst(@org.checkerframework.checker.index.qual.NonNegative int itemIndex)
    Reads a numeric or string constant pool item in code.
    final Object
    Reads the index of a constant item in code, incrementing codeIndex by 2.
    protected final Object
    readConstItem(@org.checkerframework.checker.index.qual.NonNegative int u2CodeIndex)
     
    final double
     
    protected final double
    readDouble(@org.checkerframework.checker.index.qual.NonNegative int s8CodeIndex)
     
    final float
     
    protected final float
    readFloat(@org.checkerframework.checker.index.qual.NonNegative int s4CodeIndex)
     
    final int
    Reads a signed int value in code, incrementing codeIndex by 4.
    protected final int
    readInt(@org.checkerframework.checker.index.qual.NonNegative int s4CodeIndex)
    Reads a signed int value in code.
    final @org.checkerframework.checker.index.qual.NonNegative int
    Reads an item index in code, incrementing codeIndex by 2.
    final @org.checkerframework.checker.index.qual.NonNegative int
    readItem(@org.checkerframework.checker.index.qual.NonNegative int u2CodeIndex)
     
    final long
    Reads a signed long value in code, incrementing codeIndex by 8.
    protected final long
    readLong(@org.checkerframework.checker.index.qual.NonNegative int s8CodeIndex)
    Reads a signed long value in code.
     
    protected final MethodHandle
    readMethodHandleItem(@org.checkerframework.checker.index.qual.NonNegative int bsmCodeIndex)
     
    final String
    Reads a class descriptor in code, incrementing codeIndex by 2.
    final String
    readNonnullClass(@org.checkerframework.checker.index.qual.NonNegative int u2CodeIndex)
     
    final String
    Reads the index of an UTF8 item in code, incrementing codeIndex by 2.
    final String
    readNonnullUTF8(@org.checkerframework.checker.index.qual.NonNegative int u2CodeIndex)
    Reads the index of an UTF8 item in code.
    protected final short
    Reads a signed short value in code, incrementing codeIndex by 2.
    protected final short
    readShort(@org.checkerframework.checker.index.qual.NonNegative int u2CodeIndex)
    Reads a signed short value in code.
    final int
    Reads a signed byte value in code, incrementing codeIndex by 1.
    final String
    readString(@org.checkerframework.checker.index.qual.NonNegative int itemIndex)
    Reads a string in strings at the given index.
    final @org.checkerframework.checker.index.qual.NonNegative int
    Reads an unsigned byte value in code, incrementing codeIndex by 1.
    protected final @org.checkerframework.checker.index.qual.NonNegative int
    readUnsignedByte(@org.checkerframework.checker.index.qual.NonNegative int u1CodeIndex)
    Reads an unsigned byte value in code.
    final @org.checkerframework.checker.index.qual.NonNegative int
    Reads an unsigned short value in code, incrementing codeIndex by 2.
    protected final @org.checkerframework.checker.index.qual.NonNegative int
    readUnsignedShort(@org.checkerframework.checker.index.qual.NonNegative int u2CodeIndex)
    Reads an unsigned short value in code.
    protected final String
    Reads an UTF8 string constant pool item in code, incrementing codeIndex by 2.
    protected final String
    readUTF8(@org.checkerframework.checker.index.qual.NonNegative int u2CodeIndex)
    Reads an UTF8 string constant pool item in code.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 @org.checkerframework.checker.index.qual.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 @org.checkerframework.checker.index.qual.NonNegative int readUnsignedByte()
      Reads an unsigned byte value in code, incrementing codeIndex by 1.
      Returns:
      the int
    • readUnsignedByte

      protected final @org.checkerframework.checker.index.qual.NonNegative int readUnsignedByte(@org.checkerframework.checker.index.qual.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(@org.checkerframework.checker.index.qual.NonNegative int s4CodeIndex)
    • readBoolean

      protected final boolean readBoolean(@org.checkerframework.checker.index.qual.NonNegative int s4CodeIndex)
    • readUnsignedShort

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

      protected final @org.checkerframework.checker.index.qual.NonNegative int readUnsignedShort(@org.checkerframework.checker.index.qual.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(@org.checkerframework.checker.index.qual.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(@org.checkerframework.checker.index.qual.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(@org.checkerframework.checker.index.qual.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(@org.checkerframework.checker.index.qual.NonNegative int s8CodeIndex)
    • readFloat

      public final float readFloat()
    • readFloat

      protected final float readFloat(@org.checkerframework.checker.index.qual.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(@org.checkerframework.checker.index.qual.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(@org.checkerframework.checker.index.qual.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(@org.checkerframework.checker.index.qual.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(@org.checkerframework.checker.index.qual.NonNegative int u2CodeIndex)
    • readConst

      @NonNull protected final Object readConst(@org.checkerframework.checker.index.qual.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(@org.checkerframework.checker.index.qual.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(@org.checkerframework.checker.index.qual.NonNegative int u2CodeIndex)
    • readItem

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

      public final @org.checkerframework.checker.index.qual.NonNegative int readItem(@org.checkerframework.checker.index.qual.NonNegative int u2CodeIndex)