Class InstructionFactory


  • public final class InstructionFactory
    extends Object
    Decodes raw bytecode into Instruction objects.
    • Method Detail

      • parse

        public static List<Instruction> parse​(byte[] code,
                                              ConstPool constPool)
        Parses a method body into its instructions, in offset order.
        Parameters:
        code - the method bytecode
        constPool - the class's constant pool for operand resolution
        Returns:
        the decoded instructions in offset order
      • createInstruction

        public static Instruction createInstruction​(int opcode,
                                                    int offset,
                                                    byte[] bytecode,
                                                    ConstPool constPool)
        Decodes the single instruction starting at an offset, reading its operands from the bytecode.
        Parameters:
        opcode - the opcode byte at the offset
        offset - the bytecode offset of the instruction
        bytecode - the full method bytecode
        constPool - the class's constant pool for operand resolution
        Returns:
        the decoded instruction