All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class harpoon.ClassFile.Raw.Attribute.AttributeCode

java.lang.Object
   |
   +----harpoon.ClassFile.Raw.Attribute.Attribute
           |
           +----harpoon.ClassFile.Raw.Attribute.AttributeCode

public class AttributeCode
extends Attribute
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 auxilliary information for a single Java method, instance initialization method, or class or interface initialization method. There must be exactly one Code attribute in each method_info structure.

Version:
$Id: AttributeCode.java,v 1.13 1998/10/11 03:01:13 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
AttributeLineNumberTable, AttributeLocalVariableTable, Attribute, MethodInfo, ClassFile

Variable Index

 o attributes
Each value of the attributes table must be a variable-length attribute structure.
 o code
The code array gives the actual bytes of Java Virtual Machine code that implement the method.
 o exception_table
Each entry in the exception_table array describes one exception handler in the code array.
 o max_locals
The value of the max_locals item gives the number of local variables used by this method, including the parameters passes to the method on invocation.
 o max_stack
The value of the max_stack item gives the maximum number of words on the operand stack at any point during execution of this method.

Constructor Index

 o AttributeCode(ClassFile, int, int, int, byte[], ExceptionTable[], Attribute[])
Constructor.

Method Index

 o attribute_length()
The value of the attribute_length item indicates the length of the attribute, excluding the initial six bytes.
 o attributes_count()
 o code_length()
 o constant(int)
Lookup a Constant in the constant_pool.
 o exception_table_length()
 o localName(int, int)
Return the symbolic name of a local variable, or null if one cannot be found.
 o print(PrintWriter, int)
Pretty-print the contents of this attribute.
 o write(ClassDataOutputStream)
Write to bytecode stream.

Variables

 o max_stack
 public int max_stack
The value of the max_stack item gives the maximum number of words on the operand stack at any point during execution of this method.

 o max_locals
 public int max_locals
The value of the max_locals item gives the number of local variables used by this method, including the parameters passes to the method on invocation. The index of the first local variable is 0.

 o code
 public byte code[]
The code array gives the actual bytes of Java Virtual Machine code that implement the method.

 o exception_table
 public ExceptionTable exception_table[]
Each entry in the exception_table array describes one exception handler in the code array.

 o attributes
 public Attribute attributes[]
Each value of the attributes table must be a variable-length attribute structure. A Code attribute can have any number of optional attributes associated with it.

Currently, the LinueNumberTable and LocalVariableTable attributes, both of which contain debugging information, are defined and used with the Code attribute.

Constructors

 o AttributeCode
 public AttributeCode(ClassFile parent,
                      int attribute_name_index,
                      int max_stack,
                      int max_locals,
                      byte code[],
                      ExceptionTable exception_table[],
                      Attribute attributes[])
Constructor.

Methods

 o code_length
 public long code_length()
 o exception_table_length
 public int exception_table_length()
 o attributes_count
 public int attributes_count()
 o attribute_length
 public long attribute_length()
The value of the attribute_length item indicates the length of the attribute, excluding the initial six bytes.

Overrides:
attribute_length in class Attribute
 o write
 public void write(ClassDataOutputStream out) throws IOException
Write to bytecode stream.

Overrides:
write in class Attribute
 o localName
 public String localName(int pc,
                         int index)
Return the symbolic name of a local variable, or null if one cannot be found.

Parameters:
index - the index of the local variable to look up.
Returns:
the name of the local, or null.
 o constant
 public Constant constant(int index)
Lookup a Constant in the constant_pool. Provided for use of methods that parse the code array.

 o print
 public void print(PrintWriter pw,
                   int indent)
Pretty-print the contents of this attribute.

Parameters:
indent - the indentation level to use.
Overrides:
print in class Attribute

All Packages  Class Hierarchy  This Package  Previous  Next  Index