jef.dna.instructions
Interface Instruction

All Superinterfaces:
BytesCountable, java.lang.Cloneable
All Known Subinterfaces:
InstructionRefsCpt
All Known Implementing Classes:
AALoad, AAStore, AConst_Null, ALoad, ALoad_0, ALoad_1, ALoad_2, ALoad_3, ANewArray, AReturn, ArrayLength, AStore, AStore_0, AStore_1, AStore_2, AStore_3, AThrow, BALoad, BAStore, BiPush, CALoad, CAStore, CheckCast, D2f, D2i, D2l, DAdd, DALoad, DAStore, DCmpg, DCmpl, DConst_0, DConst_1, DDiv, DLoad, DLoad_0, DLoad_1, DLoad_2, DLoad_3, DMul, DNeg, DRem, DReturn, DStore, DStore_0, DStore_1, DStore_2, DStore_3, DSub, Dup, Dup_X1, Dup_X2, Dup2, Dup2_X1, Dup2_X2, F2d, F2i, F2l, FAdd, FALoad, FAStore, FCmpg, FCmpl, FConst_0, FConst_1, FConst_2, FDiv, FLoad, FLoad_0, FLoad_1, FLoad_2, FLoad_3, FMul, FNeg, FRem, FReturn, FStore, FStore_0, FStore_1, FStore_2, FStore_3, FSub, GetField, GetStatic, Goto, Goto_W, I2b, I2c, I2d, I2f, I2l, I2s, IAdd, IALoad, IAnd, IAStore, IConst_0, IConst_1, IConst_2, IConst_3, IConst_4, IConst_5, IConst_M1, IDiv, If_ACmpEq, If_ACmpNe, IF_ICmpeq, IF_ICmpge, IF_ICmpgt, IF_ICmple, IF_ICmplt, IF_ICmpne, Ifeq, Ifge, Ifgt, Ifle, Iflt, Ifne, IfNoNull, IfNull, IInc, ILoad, ILoad_0, ILoad_1, ILoad_2, ILoad_3, IMul, INeg, InstanceOf, InstructionAncestor, InstructionAncestorRefsCpt, InstructionRefsCpt16, InstructionRefsCpt8, InvokeInterface, InvokeSpecial, InvokeStatic, InvokeVirtual, IOr, IRem, IReturn, IShl, IShr, IStore, IStore_0, IStore_1, IStore_2, IStore_3, ISub, Iushr, IXOr, Jsr, Jsr_W, L2d, L2f, L2i, LAdd, LALoad, LAnd, LAStore, Lcmp, LConst_0, LConst_1, Ldc, Ldc_W, Ldc2_W, LDiv, LLoad, LLoad_0, LLoad_1, LLoad_2, LLoad_3, LMul, LNeg, LookupSwitch, LOr, LRem, LReturn, LShl, LShr, LStore, LStore_0, LStore_1, LStore_2, LStore_3, LSub, Lushr, LXOr, MonitorEnter, MonitorExit, MultiANewArray, New, NewArray, Nop, Pop, Pop2, PutField, PutStatic, Ret, Return, SALoad, SAStore, SiPush, Swap, TableSwitch, Wide

public interface Instruction
extends java.lang.Cloneable, BytesCountable

This interface has to be implemented by every class representing a Java bytecode instruction

Author:
frusso

Method Summary
 java.lang.Object clone()
          Performs the cloning of the current Instruction implementation.
 int fromArray(int[] bytecode, int startFrom)
          This method populates all the attributes of an Instruction implementation
 int getOpCode()
          This method returns the instruction's numeric operation code as a byte.
 int[] getOperands()
          This method returns the current operation operand stack.
 int getOperandsCount()
          This method returns the number of operands required by the bytecode instruction.
 void setOpCode(int opCode)
          This method sets the current operation code to the specified byte.
 void setOperands(int[] operands)
          This method sets the current operation's operand stack.
 void setOperandsCountPosticipated(int[] bytecode, int startFrom)
          This method should be implemented by those classes wrapping JVM instructions whose number of operands is variable.
 int[] toArray()
          This method returns the method's bytecode as an array.
 int updateRefs(int offset)
          This method must implement the logic necessary to update all the references to constant pool table's entries contained within the bytecode instruction.
 
Methods inherited from interface jef.dna.util.BytesCountable
getBytesCount
 

Method Detail

fromArray

int fromArray(int[] bytecode,
              int startFrom)
This method populates all the attributes of an Instruction implementation

Parameters:
bytecode - The bytecode array
startFrom - The index of the current instruction's mnemonic (opcode)
Returns:
int The number of the processed operands plus one, the instruction's mnemonic

toArray

int[] toArray()
This method returns the method's bytecode as an array.

Returns:
int[] The method's bytecode

getOpCode

int getOpCode()
This method returns the instruction's numeric operation code as a byte.

Returns:
int The operation code of the Java VM instruction represented as an int.

setOpCode

void setOpCode(int opCode)
This method sets the current operation code to the specified byte.

Parameters:
opCode - The int representation of the operation code.

setOperandsCountPosticipated

void setOperandsCountPosticipated(int[] bytecode,
                                  int startFrom)
This method should be implemented by those classes wrapping JVM instructions whose number of operands is variable. This method is called by the fromArray method defined in the InstructionAncestor class. InstructionAncestor already contains an empty implementation of this method, useful for those classes exposing a prefixed number of operands. In such a case there is no need to override the setOperandsCountPosticipated method,

Parameters:
bytecode - The method's bytecode
startFrom - The index of the current instruction's mnemonic (opcode)

getOperands

int[] getOperands()
This method returns the current operation operand stack.

Returns:
int[] The operands this instruction has to deal with.

setOperands

void setOperands(int[] operands)
This method sets the current operation's operand stack.

Parameters:
operands - The operand stack as a int array.

updateRefs

int updateRefs(int offset)
This method must implement the logic necessary to update all the references to constant pool table's entries contained within the bytecode instruction.

Parameters:
offset - The offset used for updating expressed as number of cpt's entries to be skipped
Returns:
int The number of processed words within the current bytecode instruction

getOperandsCount

int getOperandsCount()
This method returns the number of operands required by the bytecode instruction. This information is useful for calling the setOperands method with the right number of bytes as input parametr.

Returns:
int The number of operands.

clone

java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Performs the cloning of the current Instruction implementation.

Returns:
The clone
Throws:
java.lang.CloneNotSupportedException