org.apache.tomcat.util.bcel.classfile
Class Code
java.lang.Object
org.apache.tomcat.util.bcel.classfile.Attribute
org.apache.tomcat.util.bcel.classfile.Code
- All Implemented Interfaces:
- Serializable, Cloneable
public final class Code
- extends Attribute
This class represents a chunk of Java byte code contained in a
method. 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:
- $Id: Code.java 1181133 2011-10-10 18:49:14Z markt $
- Author:
- M. Dahm
- See Also:
Attribute
,
CodeException
,
LineNumberTable
,
LocalVariableTable
,
Serialized Form
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 Codelength
- Content length in bytesmax_stack
- Maximum size of stackmax_locals
- Number of local variablescode
- Actual byte codeexception_table
- Table of handled exceptionsattributes
- Attributes of code: LineNumber or LocalVariableconstant_pool
- Array of constants
dump
public final void dump(DataOutputStream file)
throws IOException
- Dump code attribute to file stream in binary format.
- Overrides:
dump
in class Attribute
- Parameters:
file
- Output file stream
- Throws:
IOException
getLocalVariableTable
public LocalVariableTable getLocalVariableTable()
- Returns:
- LocalVariableTable of Code, if it has one
setAttributes
public final void setAttributes(Attribute[] attributes)
- Parameters:
attributes
- the attributes to set for this Code
setCode
public final void setCode(byte[] code)
- Parameters:
code
- byte code
setExceptionTable
public final void setExceptionTable(CodeException[] exception_table)
- Parameters:
exception_table
- exception table
toString
public final String toString(boolean verbose)
- Returns:
- String representation of code chunk.
toString
public final String toString()
- Overrides:
toString
in class Attribute
- Returns:
- String representation of code chunk.
copy
public Attribute copy(ConstantPool _constant_pool)
- Specified by:
copy
in class Attribute
- Parameters:
_constant_pool
- the constant pool to duplicate
- Returns:
- deep copy of this attribute
Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.