jef.dna.attributes
Interface CodeAttribute

All Superinterfaces:
Attribute, BytesCountable, java.lang.Cloneable
All Known Implementing Classes:
Code

public interface CodeAttribute
extends Attribute

The Code class represents a Code Attribute as defined by the JVM Class file Specification: The Code attribute is a variable-length attribute used in the attributes table of method_info structures. A Code attribute contains the Java virtual machine instructions and auxiliary information for a single method, instance initialization method or class or interface initialization method. Every Java virtual machine implementation must recognize Code attributes. If the method is either native or abstract, its method_info structure must not have a Code attribute. Otherwise, its method_info structure must have exactly one Code attribute.

Author:
Francesco Russo frusso@cs.unibo.it

Method Summary
 java.util.List<Instruction> generateObjectiveCode(int[] bytecode)
          This private method generates an object oriented representation of the bytecode contained within this method.
 int getAttributeCount()
          Gets the number of attributes of the current Code attribute.
 java.util.List<Attribute> getAttributes()
          Gets the set of attributes associated with the current Code attribute.
 int[] getCode()
          This method gets this Code Attribute's bytecode, as an int array.
 int getCodeLength()
          Gets the numeber of bytes making up this method's actual code.
 java.util.List<ExceptionTableEntry> getExceptionTable()
          Gets the exception table.
 int getExceptionTableLength()
          Gets the number of entries in stored within the Exceptio Table
 int getMaxLocals()
          Gets the number of local variables allocated upon method invocation.
 int getMaxStack()
          Gets the maximum depth of this method's operand stack during execution.
 java.util.List<Instruction> getObjectiveCode()
          This method returns the object oriented representation of this method's code.
 void setCode(int[] code)
          This method sets this Code Attribute's bytecode, as an int array.
 void setMaxLocals(int maxLocals)
          Sets the number of local variables allocated upon method invocation.
 void setMaxStack(int maxStack)
          Sets the maximum depth of this method's operand stack during execution.
 void validateRefIntoCode(int ref)
          Test whether the ref index refers to a valid opcode within the code array or not.
 
Methods inherited from interface jef.dna.attributes.Attribute
clone, fromStream, getDna, getLength, getNameIndex, setDna, setNameIndex, toStream, updateRefs, validate
 
Methods inherited from interface jef.dna.util.BytesCountable
getBytesCount
 

Method Detail

setMaxStack

void setMaxStack(int maxStack)
Sets the maximum depth of this method's operand stack during execution.

Parameters:
maxStack - Stack maximum depth

getMaxStack

int getMaxStack()
Gets the maximum depth of this method's operand stack during execution.

Returns:
int Stack maximum depth

setMaxLocals

void setMaxLocals(int maxLocals)
Sets the number of local variables allocated upon method invocation.

Parameters:
maxLocals - Number of allocated local variables

getMaxLocals

int getMaxLocals()
Gets the number of local variables allocated upon method invocation.

Returns:
int Number of allocated local variables

getCodeLength

int getCodeLength()
Gets the numeber of bytes making up this method's actual code. This value must strictly be greater than zero.

Returns:
int Number of bytes in the code array

getExceptionTableLength

int getExceptionTableLength()
Gets the number of entries in stored within the Exceptio Table

Returns:
int Number of entries

getExceptionTable

java.util.List<ExceptionTableEntry> getExceptionTable()
Gets the exception table. This is a table describing exception handlers in the code array. It is represented as a Listctor instance, containing ExceptionTableEntry instances.

Returns:
List The List of instances

getAttributeCount

int getAttributeCount()
Gets the number of attributes of the current Code attribute.

Returns:
int The number of attributes

getAttributes

java.util.List<Attribute> getAttributes()
Gets the set of attributes associated with the current Code attribute. This set is represented by a List holding instances of subclasses of the GenericAttribute base class.

Returns:
List Set of attributes

getObjectiveCode

java.util.List<Instruction> getObjectiveCode()
This method returns the object oriented representation of this method's code.

Returns:
List The object or. code representation generated by the generateObjectiveCode method.

generateObjectiveCode

java.util.List<Instruction> generateObjectiveCode(int[] bytecode)
This private method generates an object oriented representation of the bytecode contained within this method.

Parameters:
bytecode - The method's bytecode
Returns:
List The object oriented code representation

setCode

void setCode(int[] code)
This method sets this Code Attribute's bytecode, as an int array.

Parameters:
code - The code as int array

getCode

int[] getCode()
This method gets this Code Attribute's bytecode, as an int array.

Returns:
int[] The code as int array

validateRefIntoCode

void validateRefIntoCode(int ref)
                         throws UnknownOpCodeException,
                                MissingDnaContainerException,
                                java.lang.IndexOutOfBoundsException
Test whether the ref index refers to a valid opcode within the code array or not.

Parameters:
ref - An index into the code array
Throws:
UnknownOpCodeException - One of the instructions of the current attribute is not recognized
MissingDnaContainerException - There is no reference to the Dna instance this attribute belongs to
java.lang.IndexOutOfBoundsException - Error during processing