fr.umlv.corosol.classfile.attribute
Interface JCodeAttribute

All Superinterfaces:
JAttribute, JClassFileItem, JObject
All Known Implementing Classes:
DefaultJCodeAttribute

public interface JCodeAttribute
extends JAttribute

A JCodeAttribute object represents an Code attribute.

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.

For a given method, a Code attribute describes :

Author:
Christophe Deleray

Field Summary
 
Fields inherited from interface fr.umlv.corosol.classfile.attribute.JAttribute
CODE, CONSTANT_VALUE, DEPRECATED, EXCEPTIONS, INNER_CLASSES, LINE_NUMBER_TABLE, LOCAL_VARIABLE_TABLE, SOURCE_FILE, SYNTHETIC
 
Method Summary
 void addBytecode(int opcode)
          Adds the specified byte code to the byte code handled by this Code attribute.
 void addBytecodes(byte[] b, int off, int len)
          Adds len bytes from the specified byte array starting at offset off to the byte code handled by this Code attribute.
 void addByteOpBytecode(int opcode, int operand)
          Adds the specified byte code and its byte operand to the byte code handled by this Code attribute.
 void addClassOpBytecode(int opcode, java.lang.String className)
          Adds the specified byte code and its short operand determined by the name of a class.
 void addFieldOpBytecode(int opcode, java.lang.String className, java.lang.String name, java.lang.String desc)
          Adds the specified byte code and its short operand determined by the declaring class, the name and the descriptor of a field.
 void addIntOpBytecode(int opcode, int operand)
          Adds the specified byte code and its int operand to the byte code handled by this Code attribute.
 void addInvokeinterface(java.lang.String className, java.lang.String name, java.lang.String desc)
          Adds the invokeinterface byte code and its short operand determined by the declaring class, the name and the descriptor of an interface method.
 void addMethodOpBytecode(int opcode, java.lang.String className, java.lang.String name, java.lang.String desc)
          Adds the specified byte code and its short operand determined by the declaring class, the name and the descriptor of a method.
 void addShortOpBytecode(int opcode, int operand)
          Adds the specified byte code and its short operand to the byte code handled by this Code attribute.
 JAttribute[] getAttributes()
          Returns an array of optional attributes associated with this Code attribute.
 byte[] getByteCode()
          Returns the bytecode of a method.
 JExceptionHandler[] getExceptionHandlers()
          Returns an array containg the exception handlers in the byte code array of a method.
 int getMaxLocals()
          Returns the number of local variables in the local variable array allocated upon invocation of a method, including the local variables used to pass parameters to this method on its invocation.
 int getMaxStack()
          Returns the maximum depth of the operand stack at any point during execution of a method.
 void setAttributes(JAttribute[] attributes)
          Sets the optional attributes associated with this Code attribute.
 void setByteCode(byte[] byteCode)
          Sets the bytecode of a method whith the specified byte array.
 void setExceptionHandlers(JExceptionHandler[] handlers)
          Sets the exception handlers in the byte code of a method.
 void setMaxLocals(int maxLocals)
          Sets the number of local variables in the local variable array allocated upon invocation of a method, including the local variables used to pass parameters to this method on its invocation.
 void setMaxStack(int maxStack)
          Sets the maximum depth of the operand stack at any point during execution of a method.
 
Methods inherited from interface fr.umlv.corosol.classfile.attribute.JAttribute
getName, getSize, toString
 
Methods inherited from interface fr.umlv.corosol.classfile.JClassFileItem
getConstantPool, readItem, setConstantPool, writeItem
 

Method Detail

getMaxStack

int getMaxStack()
Returns the maximum depth of the operand stack at any point during execution of a method.


getMaxLocals

int getMaxLocals()
Returns the number of local variables in the local variable array allocated upon invocation of a method, including the local variables used to pass parameters to this method on its invocation.


getByteCode

byte[] getByteCode()
Returns the bytecode of a method.


getExceptionHandlers

JExceptionHandler[] getExceptionHandlers()
Returns an array containg the exception handlers in the byte code array of a method.


getAttributes

JAttribute[] getAttributes()
Returns an array of optional attributes associated with this Code attribute.


setMaxStack

void setMaxStack(int maxStack)
Sets the maximum depth of the operand stack at any point during execution of a method.

Parameters:
maxStack - the max size of the operand stack of a frame

setMaxLocals

void setMaxLocals(int maxLocals)
Sets the number of local variables in the local variable array allocated upon invocation of a method, including the local variables used to pass parameters to this method on its invocation.

Parameters:
maxLocals - the max size of the local variable array of a frame

setByteCode

void setByteCode(byte[] byteCode)
Sets the bytecode of a method whith the specified byte array.

Parameters:
byteCode - the bytecode of a method

setExceptionHandlers

void setExceptionHandlers(JExceptionHandler[] handlers)
Sets the exception handlers in the byte code of a method.

Parameters:
handlers - the exception handlers of the byte code of a method

setAttributes

void setAttributes(JAttribute[] attributes)
Sets the optional attributes associated with this Code attribute.

Parameters:
attributes - an array of optional attributes

addBytecode

void addBytecode(int opcode)
Adds the specified byte code to the byte code handled by this Code attribute.

Parameters:
opcode - the opcode of a byte code instruction

addByteOpBytecode

void addByteOpBytecode(int opcode,
                       int operand)
Adds the specified byte code and its byte operand to the byte code handled by this Code attribute.

Parameters:
opcode - the opcode of a byte code instruction
operand - the byte operand of the instruction

addShortOpBytecode

void addShortOpBytecode(int opcode,
                        int operand)
Adds the specified byte code and its short operand to the byte code handled by this Code attribute.

Parameters:
opcode - the opcode of a byte code instruction
operand - the short operand of the instruction

addIntOpBytecode

void addIntOpBytecode(int opcode,
                      int operand)
Adds the specified byte code and its int operand to the byte code handled by this Code attribute.

Parameters:
opcode - the opcode of a byte code instruction
operand - the int operand of the instruction

addBytecodes

void addBytecodes(byte[] b,
                  int off,
                  int len)
Adds len bytes from the specified byte array starting at offset off to the byte code handled by this Code attribute.

Parameters:
b - the byte code data.
off - the start offset in the data.
len - the number of bytes to write.

addClassOpBytecode

void addClassOpBytecode(int opcode,
                        java.lang.String className)
Adds the specified byte code and its short operand determined by the name of a class. This operand is an index of a Constant\_Class\_info constant pool entry.

Parameters:
opcode - the opcode of a byte code instruction
className - the name of a class

addMethodOpBytecode

void addMethodOpBytecode(int opcode,
                         java.lang.String className,
                         java.lang.String name,
                         java.lang.String desc)
Adds the specified byte code and its short operand determined by the declaring class, the name and the descriptor of a method. This operand is an index of a Constant\_Methodref\_info constant pool entry.

Parameters:
opcode - the opcode of a byte code instruction
className - the declaring class of a method
name - the name of a method
desc - the name of a method

addInvokeinterface

void addInvokeinterface(java.lang.String className,
                        java.lang.String name,
                        java.lang.String desc)
Adds the invokeinterface byte code and its short operand determined by the declaring class, the name and the descriptor of an interface method. This operand is an index of a Constant\_InterfaceMethodref\_info constant pool entry.

Parameters:
className - the declaring class of an interface method
name - the name of an interface method
desc - the name of an interface method

addFieldOpBytecode

void addFieldOpBytecode(int opcode,
                        java.lang.String className,
                        java.lang.String name,
                        java.lang.String desc)
Adds the specified byte code and its short operand determined by the declaring class, the name and the descriptor of a field. This operand is an index of a Constant\_Fieldref\_info constant pool entry.

Parameters:
opcode - the opcode of a byte code instruction
className - the declaring class of a field
name - the name of a field
desc - the name of a field