Class LdcWInstruction


  • public class LdcWInstruction
    extends Instruction
    Represents the LDC_W instruction (0x13).
    • Constructor Detail

      • LdcWInstruction

        public LdcWInstruction​(ConstPool constPool,
                               int opcode,
                               int offset,
                               int cpIndex)
        Constructs an LdcWInstruction.
        Parameters:
        constPool - The constant pool associated with the class.
        opcode - The opcode of the instruction.
        offset - The bytecode offset of the instruction.
        cpIndex - The constant pool index.
    • Method Detail

      • getCpIndex

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

        public void write​(DataOutputStream dos)
                   throws IOException
        Writes the LDC_W 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).
      • 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).
      • getConstantType

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

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

        public String resolveConstant()
        Renders the referenced constant as display text.
        Returns:
        the quoted string, numeric value, class name, or handle/type/dynamic description; an INVALID_CP_INDEX or "UnknownConstant" marker otherwise
      • 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.