Class GetFieldInstruction


  • public class GetFieldInstruction
    extends Instruction
    Represents the JVM GETFIELD and GETSTATIC instructions.
    • Constructor Detail

      • GetFieldInstruction

        public GetFieldInstruction​(ConstPool constPool,
                                   int opcode,
                                   int offset,
                                   int fieldIndex)
        Constructs a GetFieldInstruction.
        Parameters:
        constPool - The constant pool associated with the class.
        opcode - The opcode of the instruction.
        offset - The bytecode offset of the instruction.
        fieldIndex - The constant pool index for the field reference.
        Throws:
        IllegalArgumentException - if the opcode is not GETFIELD or GETSTATIC
    • Method Detail

      • getFieldIndex

        public int getFieldIndex()
        Returns:
        the field index
      • write

        public void write​(DataOutputStream dos)
                   throws IOException
        Writes the get field 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 (depends on the field type).
      • 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).
      • resolveField

        public String resolveField()
        Resolves and returns a string representation of the field.
        Returns:
        The field as a string.
      • getFieldName

        public String getFieldName()
        Returns the field name.
        Returns:
        The field name.
      • getFieldDescriptor

        public String getFieldDescriptor()
        Returns the field descriptor.
        Returns:
        The field descriptor.
      • getOwnerClass

        public String getOwnerClass()
        Returns the owner class name.
        Returns:
        The owner class internal name.
      • isStatic

        public boolean isStatic()
        Returns whether this is a static field access.
        Returns:
        true if GETSTATIC, false if GETFIELD.
      • toString

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