TechTrader Bytecode Toolkit

com.techtrader.modules.tools.bytecode
Class MethodInstruction

java.lang.Object
  |
  +--com.techtrader.modules.tools.bytecode.Instruction
        |
        +--com.techtrader.modules.tools.bytecode.MethodInstruction

public class MethodInstruction
extends Instruction

Represents an instruction that takes as an argument a method to operate on. Examples include INVOKEINTERFACE, INVOKEVIRTUAL, etc.

Author:
Abe White

Fields inherited from class com.techtrader.modules.tools.bytecode.Instruction
_byteIndex, _opcode, _opcodeTypes, _owner
 
Constructor Summary
protected MethodInstruction(Code owner, int opcode)
           
 
Method Summary
 void acceptVisit(BCVisitor visit)
          Accept a visit from a BCVisitor, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this object.
protected  void copy(Instruction orig)
           
 boolean equals(Object other)
          Method instructions are equal if the method of either is unset, or if they refer to the same method.
 int getLength()
          Return the length in bytes of this opcode, including all arguments.
 BCMethod getMethod()
          If the method is a member of the current class, then this method will retrieve the BCMethod object for it; otherwise it will return null.
 int getMethodIndex()
          Get the index of the ComplexEntry in the constant pool describing the method to operate on.
 String getMethodName()
          Get the nam of the method to operate on.
 Class getMethodOwnerType()
          Get the type of the method.
 String getMethodOwnerTypeName()
          Get the type of the method.
 String[] getMethodParamTypeNames()
          Get the param types of the method.
 Class[] getMethodParamTypes()
          Get the param types of the method.
 Class getMethodReturnType()
          Get the return type of the method.
 String getMethodReturnTypeName()
          Get the return type of the method.
 int getStackChange()
          Return the number of stack positions this instruction pushes or pops during its execution.
 boolean isMethodInCurrentClass()
          Return true if the method is a member of the current class.
protected  void readData(DataInput in)
          Read the arguments for this opcode from the given stream.
 MethodInstruction setMethod(BCMethod method)
          Set the method to operate on.
 MethodInstruction setMethod(Constructor method)
          Set the method to operate on.
 MethodInstruction setMethod(Method method)
          Set the method to operate on.
 MethodInstruction setMethod(String name, Class returnType, Class[] paramTypes, Class ownerType)
          Set the method to operate on.
 MethodInstruction setMethod(String name, Class returnType, Class[] paramTypes, String ownerType)
          Set the method to operate on.
 MethodInstruction setMethod(String name, String returnType, String[] paramTypes, String ownerType)
          Set the method to operate on.
 void setMethodIndex(int index)
          Set the index of the ComplexEntry in the constant pool describing the method to operate on.
 MethodInstruction setMethodName(String name)
          Change the method name.
 MethodInstruction setMethodOwnerTypeName(String name)
          Change the method owner type.
 MethodInstruction setMethodParamTypeNames(String[] names)
          Change the method param types.
 MethodInstruction setMethodReturnTypeName(String name)
          Change the method return type.
protected  void writeData(DataOutput out)
          Write the arguments for this opcode to the given stream.
 
Methods inherited from class com.techtrader.modules.tools.bytecode.Instruction
getByteIndex, getName, getOpCode, getOwner, invalidate, setByteIndex, setOpCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodInstruction

protected MethodInstruction(Code owner,
                            int opcode)
Method Detail

getMethodIndex

public int getMethodIndex()
Get the index of the ComplexEntry in the constant pool describing the method to operate on.

setMethodIndex

public void setMethodIndex(int index)
Set the index of the ComplexEntry in the constant pool describing the method to operate on.

setMethod

public MethodInstruction setMethod(BCMethod method)
Set the method to operate on.
Returns:
this Instruction, for method chaining

setMethod

public MethodInstruction setMethod(Method method)
Set the method to operate on.
Returns:
this Instruction, for method chaining

setMethod

public MethodInstruction setMethod(Constructor method)
Set the method to operate on.
Returns:
this Instruction, for method chaining

setMethod

public MethodInstruction setMethod(String name,
                                   String returnType,
                                   String[] paramTypes,
                                   String ownerType)
Set the method to operate on.
Returns:
this Instruction, for method chaining

setMethod

public MethodInstruction setMethod(String name,
                                   Class returnType,
                                   Class[] paramTypes,
                                   String ownerType)
Set the method to operate on.
Returns:
this Instruction, for method chaining

setMethod

public MethodInstruction setMethod(String name,
                                   Class returnType,
                                   Class[] paramTypes,
                                   Class ownerType)
Set the method to operate on.
Returns:
this Instruction, for method chaining

setMethodName

public MethodInstruction setMethodName(String name)
Change the method name.
Returns:
this Instruction, for method chaining

setMethodOwnerTypeName

public MethodInstruction setMethodOwnerTypeName(String name)
Change the method owner type.
Returns:
this Instruction, for method chaining

setMethodReturnTypeName

public MethodInstruction setMethodReturnTypeName(String name)
Change the method return type.
Returns:
this Instruction, for method chaining

setMethodParamTypeNames

public MethodInstruction setMethodParamTypeNames(String[] names)
Change the method param types.
Returns:
this Instruction, for method chaining

isMethodInCurrentClass

public boolean isMethodInCurrentClass()
Return true if the method is a member of the current class.

getMethod

public BCMethod getMethod()
If the method is a member of the current class, then this method will retrieve the BCMethod object for it; otherwise it will return null.

getMethodName

public String getMethodName()
Get the nam of the method to operate on.

getMethodReturnTypeName

public String getMethodReturnTypeName()
Get the return type of the method.

getMethodReturnType

public Class getMethodReturnType()
                          throws ClassNotFoundException
Get the return type of the method.

getMethodParamTypeNames

public String[] getMethodParamTypeNames()
Get the param types of the method.

getMethodParamTypes

public Class[] getMethodParamTypes()
                            throws ClassNotFoundException
Get the param types of the method.

getMethodOwnerTypeName

public String getMethodOwnerTypeName()
Get the type of the method.

getMethodOwnerType

public Class getMethodOwnerType()
                         throws ClassNotFoundException
Get the type of the method.

equals

public boolean equals(Object other)
Method instructions are equal if the method of either is unset, or if they refer to the same method.
Overrides:
equals in class Instruction

getLength

public int getLength()
Description copied from class: Instruction
Return the length in bytes of this opcode, including all arguments. This method should be overridden by opcodes that take arguments.
Overrides:
getLength in class Instruction

getStackChange

public int getStackChange()
Description copied from class: Instruction
Return the number of stack positions this instruction pushes or pops during its execution.
Overrides:
getStackChange in class Instruction
Tags copied from class: Instruction
Returns:
0 if the stack is not affected by this instruction, a positive number if it pushes onto the stack, and a negative number if it pops from the stack

copy

protected void copy(Instruction orig)
Overrides:
copy in class Instruction

readData

protected void readData(DataInput in)
                 throws IOException
Description copied from class: Instruction
Read the arguments for this opcode from the given stream. This method should be overridden by opcodes that take arguments.
Overrides:
readData in class Instruction

writeData

protected void writeData(DataOutput out)
                  throws IOException
Description copied from class: Instruction
Write the arguments for this opcode to the given stream. This method should be overridden by opcodes that take arguments.
Overrides:
writeData in class Instruction

acceptVisit

public void acceptVisit(BCVisitor visit)
Description copied from interface: VisitAcceptor
Accept a visit from a BCVisitor, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this object.
Overrides:
acceptVisit in class Instruction

TechTrader Bytecode Toolkit