All Packages Class Hierarchy This Package Previous Next Index
Class espresso.classfile.javaclass.Code
java.lang.Object
|
+----espresso.classfile.javaclass.Attribute
|
+----espresso.classfile.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.
- See Also:
- Attribute, CodeException, LineNumberTable, LocalVariableTable
-
attributes
-
-
attributes_count
-
-
code
-
-
code_length
-
-
constant_pool
-
-
exception_table
-
-
exception_table_length
-
-
max_locals
-
-
max_stack
-
-
Code()
- Empty constructor, all attributes have to be defined via `setXXX'
methods.
-
Code(Code)
- Initialize from another object.
-
Code(int, int, DataInputStream, ConstantPool)
-
-
Code(int, int, int, int, byte[], CodeException[], Attribute[], ConstantPool)
-
-
accept(Visitor)
- Called by objects that are traversing the nodes of the tree implicitely
defined by the contents of a Java class.
-
dump(DataOutputStream)
- Dump code attribute to file stream in binary format.
-
getAttributes()
-
-
getCode()
-
-
getConstantPool()
-
-
getExceptionTable()
-
-
getMaxLocals()
-
-
getMaxStack()
-
-
setAttributes(Attribute[])
-
-
setCode(byte[])
-
-
setConstantPool(ConstantPool)
-
-
setExceptionTable(CodeException[])
-
-
setMaxLocals(int)
-
-
setMaxStack(int)
-
-
toString()
-
max_stack
private int max_stack
max_locals
private int max_locals
code_length
private int code_length
code
private byte code[]
exception_table_length
private int exception_table_length
exception_table
private CodeException exception_table[]
attributes_count
private int attributes_count
attributes
private Attribute attributes[]
constant_pool
private ConstantPool constant_pool
Code
public Code()
- Empty constructor, all attributes have to be defined via `setXXX'
methods. Use at your own risk.
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.
Code
Code(int name_index,
int length,
DataInputStream file,
ConstantPool constant_pool) throws IOException
- Parameters:
- name_index - Index pointing to the name Code
- length - Content length in bytes
- file - Input stream
- constant_pool - Array of constants
Code
public Code(int name_index,
int length,
int max_stack,
int 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
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
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
getAttributes
public final Attribute[] getAttributes()
- Returns:
- Collection of code attributes.
- See Also:
- Attribute
getCode
public final byte[] getCode()
- Returns:
- Actual byte code of the method.
getConstantPool
public final ConstantPool getConstantPool()
- Returns:
- Constant pool used by this object.
- See Also:
- ConstantPool
getExceptionTable
public final CodeException[] getExceptionTable()
- Returns:
- Table of handled exceptions.
- See Also:
- CodeException
getMaxLocals
public final int getMaxLocals()
- Returns:
- Number of local variables.
getMaxStack
public final int getMaxStack()
- Returns:
- Maximum size of stack used by this method.
setAttributes
public final void setAttributes(Attribute attributes[])
setCode
public final void setCode(byte code[])
- Parameters:
- code - byte code
setConstantPool
public final void setConstantPool(ConstantPool constant_pool)
- Parameters:
- constant_pool - Constant pool to be used for this object.
- See Also:
- ConstantPool
setExceptionTable
public final void setExceptionTable(CodeException exception_table[])
- Parameters:
- exception_table - exception table
setMaxLocals
public final void setMaxLocals(int max_locals)
- Parameters:
- max_locals - maximum number of local variables
setMaxStack
public final void setMaxStack(int max_stack)
- Parameters:
- max_stack - maximum stack size
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