Class LdcInstruction


  • public class LdcInstruction
    extends Instruction
    Represents the LDC instruction (0x12).
    • Constructor Detail

      • LdcInstruction

        public LdcInstruction​(ConstPool constPool,
                              int opcode,
                              int offset,
                              int cpIndex)
        Constructs an LdcInstruction.
        Parameters:
        constPool - The constant pool associated with the class.
        opcode - The nominal opcode (ignored; the form is derived from cpIndex).
        offset - The bytecode offset of the instruction.
        cpIndex - The constant pool index.
    • Method Detail

      • getCpIndex

        public int getCpIndex()
        Returns:
        the cp index
      • getConstPool

        public ConstPool getConstPool()
        Returns:
        the const pool
      • write

        public void write​(DataOutputStream dos)
                   throws IOException
        Writes the LDC opcode and its operand to the DataOutputStream.
        Specified by:
        write in class Instruction
        Parameters:
        dos - The DataOutputStream to write to.
        Throws:
        IOException - If an I/O error occurs.
      • getStackChange

        public int getStackChange()
        Returns the change in stack size caused by this instruction.
        Specified by:
        getStackChange in class Instruction
        Returns:
        The stack size change (pushes a reference or primitive).
      • getConstantType

        public LdcInstruction.ConstantType getConstantType()
        Classifies the referenced constant-pool entry.
        Returns:
        the constant kind, or UNKNOWN for an invalid index or unrecognized entry
      • getLocalChange

        public int getLocalChange()
        Returns the change in local variables caused by this instruction.
        Specified by:
        getLocalChange in class Instruction
        Returns:
        The local variables size change (none).
      • resolveConstant

        public String resolveConstant()
        Resolves and returns a string representation of the constant.
        Returns:
        The constant as a string.
      • toString

        public String toString()
        Returns a string representation of the instruction.
        Overrides:
        toString in class Instruction
        Returns:
        The mnemonic, constant pool index, and resolved constant.