Package com.tonic.analysis.instruction
Class PutFieldInstruction
- java.lang.Object
-
- com.tonic.analysis.instruction.Instruction
-
- com.tonic.analysis.instruction.PutFieldInstruction
-
public class PutFieldInstruction extends Instruction
Represents the PUTFIELD and PUTSTATIC instructions (0xB5, 0xB3).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPutFieldInstruction.FieldTypeThe field-write kinds (instance PUTFIELD vs static PUTSTATIC), each pairing a JVM opcode with its mnemonic.
-
Constructor Summary
Constructors Constructor Description PutFieldInstruction(ConstPool constPool, int opcode, int offset, int fieldIndex)Constructs a PutFieldInstruction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(AbstractBytecodeVisitor visitor)Accepts a visitor for bytecode analysis.StringgetFieldDescriptor()Returns the field descriptor.intgetFieldIndex()Returns the field index used by this instruction.StringgetFieldName()Returns the field name.intgetLocalChange()Returns the change in local variables caused by this instruction.StringgetOwnerClass()Returns the owner class name.intgetStackChange()Returns the change in stack size caused by this instruction.booleanisStatic()Returns whether this is a static field access.StringresolveField()Resolves and returns a string representation of the field.StringtoString()Returns a string representation of the instruction.voidwrite(DataOutputStream dos)Writes the put field opcode and its operand to the DataOutputStream.-
Methods inherited from class com.tonic.analysis.instruction.Instruction
getLength, getOffset, getOpcode, setOffset
-
-
-
-
Constructor Detail
-
PutFieldInstruction
public PutFieldInstruction(ConstPool constPool, int opcode, int offset, int fieldIndex)
Constructs a PutFieldInstruction.- 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 PUTFIELD or PUTSTATIC
-
-
Method Detail
-
accept
public void accept(AbstractBytecodeVisitor visitor)
Description copied from class:InstructionAccepts a visitor for bytecode analysis.- Specified by:
acceptin classInstruction- Parameters:
visitor- The visitor to accept.
-
write
public void write(DataOutputStream dos) throws IOException
Writes the put field opcode and its operand to the DataOutputStream.- Specified by:
writein classInstruction- 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:
getStackChangein classInstruction- Returns:
- The stack size change (pops the value to store and possibly the object reference).
-
getLocalChange
public int getLocalChange()
Returns the change in local variables caused by this instruction.- Specified by:
getLocalChangein classInstruction- Returns:
- The local variables size change (none).
-
getFieldIndex
public int getFieldIndex()
Returns the field index used by this instruction.- Returns:
- The constant pool index for the field reference.
-
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 PUTSTATIC, false if PUTFIELD.
-
toString
public String toString()
Returns a string representation of the instruction.- Overrides:
toStringin classInstruction- Returns:
- The mnemonic, field index, and resolved field.
-
-