All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class DE.fub.inf.JVM.JavaClass.Code

java.lang.Object
   |
   +----DE.fub.inf.JVM.JavaClass.Attribute
           |
           +----DE.fub.inf.JVM.JavaClass.Code

public final class Code
extends Attribute
This class is derived from Attribute and represents a code chunk. It is instantiated by the Attribute.readAttribute() method. A Code attribute contains informations about operand stack, local variables, byte code and the exceptions handled within this method. This attribute has attributes itself, namely LineNumberTable which is used for debugging purposes and LocalVariableTable which contains information about the local variables.

Version:
970922
Author:
M. Dahm
See Also:
Attribute, CodeException, LineNumberTable, LocalVariableTable

Constructor Index

 o Code()
Empty constructor, all attributes have to be defined via `setXXX' methods.
 o Code(Code)
Initialize from another object.
 o Code(short, int, short, short, byte[], CodeException[], Attribute[], ConstantPool)

Method Index

 o accept(Visitor)
Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class.
 o dump(DataOutputStream)
Dump code attribute to file stream in binary format.
 o getAttributes()
 o getCode()
 o getConstantPool()
 o getExceptionTable()
 o getMaxLocals()
 o getMaxStack()
 o setAttributes(Attribute[])
 o setCode(byte[])
 o setConstantPool(ConstantPool)
 o setExceptionTable(CodeException[])
 o setMaxLocals(short)
 o setMaxStack(short)
 o toString()

Constructors

 o Code
 public Code()
Empty constructor, all attributes have to be defined via `setXXX' methods. Use at your own risk.

 o Code
 public Code(Code c)
Initialize from another object. Note that both objects use the same references (shallow copy). Use clone() for a physical copy.

 o Code
 public Code(short name_index,
             int length,
             short max_stack,
             short max_locals,
             byte code[],
             CodeException exception_table[],
             Attribute attributes[],
             ConstantPool constant_pool)
Parameters:
name_index - Index pointing to the name Code
length - Content length in bytes
max_stack - Maximum size of stack
max_locals - Number of local variables
code - Actual byte code
exception_table - Table of handled exceptions
attributes - Attributes of code: LineNumber or LocalVariable
constant_pool - Array of constants

Methods

 o accept
 public void accept(Visitor v)
Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.

Parameters:
v - Visitor object
Overrides:
accept in class Attribute
 o dump
 public final void dump(DataOutputStream file) throws IOException
Dump code attribute to file stream in binary format.

Parameters:
file - Output file stream
Overrides:
dump in class Attribute
 o getAttributes
 public final Attribute[] getAttributes()
Returns:
Collection of code attributes.
See Also:
Attribute
 o getCode
 public final byte[] getCode()
Returns:
Actual byte code of the method.
 o getConstantPool
 public final ConstantPool getConstantPool()
Returns:
Constant pool used by this object.
See Also:
ConstantPool
 o getExceptionTable
 public final CodeException[] getExceptionTable()
Returns:
Table of handled exceptions.
See Also:
CodeException
 o getMaxLocals
 public final short getMaxLocals()
Returns:
Number of local variables.
 o getMaxStack
 public final short getMaxStack()
Returns:
Maximum size of stack used by this method.
 o setAttributes
 public final void setAttributes(Attribute attributes[])
 o setCode
 public final void setCode(byte code[])
 o setConstantPool
 public final void setConstantPool(ConstantPool constant_pool)
Parameters:
constant_pool - Constant pool to be used for this object.
See Also:
ConstantPool
 o setExceptionTable
 public final void setExceptionTable(CodeException exception_table[])
 o setMaxLocals
 public final void setMaxLocals(short max_locals)
 o setMaxStack
 public final void setMaxStack(short max_stack)
 o toString
 public final String toString()
Returns:
String representation of code chunk.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index