com.objectwave.classFile
Class MethodInfo

java.lang.Object
  |
  +--com.objectwave.classFile.MethodInfo

public class MethodInfo
extends java.lang.Object

This class describes a Method as it is stored in the class file. The attribute associated with method is the code that actually implements the method. Since we don't need to manipulate the byte codes directly we leave them as an opaque chunk in the attributes[] array. References in the code are all references into the constant table so when we are modifing a class to use a different object we needn't get into the code level.

Author:
Dave Hoag
See Also:
ClassFile

Constructor Summary
MethodInfo()
           
 
Method Summary
 void addCalledMethods(java.util.Vector result, ConstantPoolInfo[] pool)
          Populate the Vector 'result' with all of the methods that this method invokes.
protected  void displayThrowsClause(java.lang.StringBuffer x)
          If the MethodInfo has exceptions declared, put them in the 'throws' clause.
protected  void fixUpConstants(ClassFile target, ConstantPoolInfo[] originalPool)
           
protected  java.lang.String formatName(java.lang.String s)
          Strip the '/' characters and replace them with '.'.
 CodeAttributeInfo getCodeAttributeInfo()
          A null value as a result means that the code could not be located.
 java.lang.String getNextParameter(int idx, char c)
          Attempt to determine the 'string' value that was used when writing the code.
 boolean read(java.io.DataInputStream di, ConstantPoolInfo[] pool)
          Read a method_info from the data stream.
 java.lang.String toString()
          Generic toString method, init method is unchanged.
 java.lang.String toString(java.lang.String className, ConstantPoolInfo[] pool)
          print out the method, much as you would see it in the source file.
 void write(java.io.DataOutputStream dos, ConstantPoolInfo[] pool)
          Write out a method_info, do constant table fixups on the write.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MethodInfo

public MethodInfo()
Method Detail

read

public boolean read(java.io.DataInputStream di,
                    ConstantPoolInfo[] pool)
             throws java.io.IOException
Read a method_info from the data stream.

java.io.IOException

toString

public java.lang.String toString()
Generic toString method, init method is unchanged.

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.lang.String className,
                                 ConstantPoolInfo[] pool)
print out the method, much as you would see it in the source file. The string ClassName is substituted for <init> when printing.


displayThrowsClause

protected void displayThrowsClause(java.lang.StringBuffer x)
If the MethodInfo has exceptions declared, put them in the 'throws' clause.

Parameters:
x - The buffer on which to write the 'throws' clause.

formatName

protected java.lang.String formatName(java.lang.String s)
Strip the '/' characters and replace them with '.'.

Parameters:
s - The string to convert.

addCalledMethods

public void addCalledMethods(java.util.Vector result,
                             ConstantPoolInfo[] pool)
Populate the Vector 'result' with all of the methods that this method invokes.


getCodeAttributeInfo

public CodeAttributeInfo getCodeAttributeInfo()
A null value as a result means that the code could not be located. Very odd.


getNextParameter

public java.lang.String getNextParameter(int idx,
                                         char c)
Attempt to determine the 'string' value that was used when writing the code. This is stored in the local variable table, but it is not required to be there.

Parameters:
idx - The index of the parameter starting at 1
c - The current random character to use as the parameter.

write

public void write(java.io.DataOutputStream dos,
                  ConstantPoolInfo[] pool)
           throws java.io.IOException,
                  java.lang.Exception
Write out a method_info, do constant table fixups on the write.

java.io.IOException
java.lang.Exception

fixUpConstants

protected void fixUpConstants(ClassFile target,
                              ConstantPoolInfo[] originalPool)
                       throws java.lang.Exception
java.lang.Exception