com.objectwave.classFile
Class CodeAttributeInfo

java.lang.Object
  |
  +--com.objectwave.classFile.AttributeInfo
        |
        +--com.objectwave.classFile.CodeAttributeInfo

public class CodeAttributeInfo
extends AttributeInfo

A specific attribute info.

See Also:
ClassFile

Constructor Summary
CodeAttributeInfo()
           
CodeAttributeInfo(ConstantPoolInfo newName, byte[] newData)
           
 
Method Summary
 void addCalledMethods(java.util.Vector result, ConstantPoolInfo[] pool)
           
 void adjustExceptionTable(short increase)
           
protected  void displayCode(java.lang.StringBuffer buff, ConstantPoolInfo[] pool)
          Only called by the MethodInfo class if the System parameter of ow.showAttributes is set to non-null.
protected  void fixUpCode(ClassFile target, ConstantPoolInfo[] originalPool)
          If this method is copied into another class, it may become necessary to fix up all references to the constants in the original pool.
protected  void fixUpConstants(ClassFile target, ConstantPoolInfo[] originalPool)
           
 ConstantPoolInfo[] getCatchTypes(ConstantPoolInfo[] pool)
          Null values in the resulting array are legal.
 java.lang.String getLocalVar(int idx)
          If there is a local var table, find the local var at the index.
protected  int handleLookupSwitch(int opCode, byte[] data, int idx, java.lang.StringBuffer buff)
          The lookupswith opcode has a variable length of data.
static void hexDump(byte[] bytes, int read, java.io.Writer writer)
          This method will print a hex dump of the given byte array to the given output stream.
 boolean read(java.io.DataInputStream di, ConstantPoolInfo[] pool)
          Code_attribute { u2 attribute_name_index; u4 attribute_length; u2 max_stack; u2 max_locals; u4 code_length; u1 code[code_length]; u2 exception_table_length; { u2 start_pc; u2 end_pc; u2 handler_pc; u2 catch_type; } exception_table[exception_table_length]; u2 attributes_count; attribute_info attributes[attributes_count];
protected  void readCodeAttributes(ConstantPoolInfo[] pool)
          Optional code attributes.
 java.lang.String toString(ConstantPoolInfo[] pool)
          Print out an 'intelligent' version of this class.
 void write(java.io.DataOutputStream dos, ConstantPoolInfo[] pool)
          Write the bytes to the output stream.
 
Methods inherited from class com.objectwave.classFile.AttributeInfo
toBoolean, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CodeAttributeInfo

public CodeAttributeInfo()

CodeAttributeInfo

public CodeAttributeInfo(ConstantPoolInfo newName,
                         byte[] newData)
Method Detail

fixUpConstants

protected void fixUpConstants(ClassFile target,
                              ConstantPoolInfo[] originalPool)
                       throws java.lang.Exception
Overrides:
fixUpConstants in class AttributeInfo
Parameters:
target -
originalPool -
Throws:
java.lang.Exception

fixUpCode

protected void fixUpCode(ClassFile target,
                         ConstantPoolInfo[] originalPool)
                  throws java.lang.Exception
If this method is copied into another class, it may become necessary to fix up all references to the constants in the original pool.

java.lang.Exception

adjustExceptionTable

public void adjustExceptionTable(short increase)

getCatchTypes

public ConstantPoolInfo[] getCatchTypes(ConstantPoolInfo[] pool)
Null values in the resulting array are legal. They represent 'finally' catch blocks.

Returns:
All of the caught types declared in the exception table.

read

public boolean read(java.io.DataInputStream di,
                    ConstantPoolInfo[] pool)
             throws java.io.IOException
Code_attribute { u2 attribute_name_index; u4 attribute_length; u2 max_stack; u2 max_locals; u4 code_length; u1 code[code_length]; u2 exception_table_length; { u2 start_pc; u2 end_pc; u2 handler_pc; u2 catch_type; } exception_table[exception_table_length]; u2 attributes_count; attribute_info attributes[attributes_count];

Overrides:
read in class AttributeInfo
Parameters:
di -
pool -
Returns:
Throws:
java.io.IOException

readCodeAttributes

protected void readCodeAttributes(ConstantPoolInfo[] pool)
                           throws java.io.IOException
Optional code attributes. These include a LocalVariableTable and the LineNumberTable.

java.io.IOException

write

public void write(java.io.DataOutputStream dos,
                  ConstantPoolInfo[] pool)
           throws java.io.IOException,
                  java.lang.Exception
Write the bytes to the output stream.

Overrides:
write in class AttributeInfo
Parameters:
dos - The DataOutputStream upon which this is writing
pool - The constant pool in which to index.
Throws:
java.io.IOException
java.lang.Exception

getLocalVar

public java.lang.String getLocalVar(int idx)
If there is a local var table, find the local var at the index.


toString

public java.lang.String toString(ConstantPoolInfo[] pool)
Description copied from class: AttributeInfo
Print out an 'intelligent' version of this class. The constant pool contains the necessary information.

Overrides:
toString in class AttributeInfo
Parameters:
pool -
Returns:

addCalledMethods

public void addCalledMethods(java.util.Vector result,
                             ConstantPoolInfo[] pool)

displayCode

protected void displayCode(java.lang.StringBuffer buff,
                           ConstantPoolInfo[] pool)
Only called by the MethodInfo class if the System parameter of ow.showAttributes is set to non-null.

Parameters:
buff - The buffer upon which information is being written.
pool - ConstantPoolInfo [] The constant pool containing strings, classes, etc...

handleLookupSwitch

protected int handleLookupSwitch(int opCode,
                                 byte[] data,
                                 int idx,
                                 java.lang.StringBuffer buff)
The lookupswith opcode has a variable length of data. This method will deal with that accordingly.

Returns:
The index of the last data element read. It is up to the user of this method to increment accordingly.

hexDump

public static void hexDump(byte[] bytes,
                           int read,
                           java.io.Writer writer)
                    throws java.io.IOException
This method will print a hex dump of the given byte array to the given output stream. Each line of the output will be 2-digit hex numbers, separated by single spaces, followed by the characters corresponding to those hex numbers, or a '.' if the given character is unprintable. Each of these numbers will correspond to a byte of the byte array.

Parameters:
bytes - the byte array to write
writer - the destination for the output.
Throws:
java.io.IOException - thrown if there's an error writing strings to the writer.