com.markcrocker.purifier
Class Frame

java.lang.Object
  |
  +--com.markcrocker.purifier.Frame

public class Frame
extends java.lang.Object

This class represents a JVM execution frame; that means, a local variable array and an operand stack.

Author:
Enver Haase, Mark Crocker

Field Summary
private  LocalVariables locals
           
private static org.apache.log4j.Logger log
           
private  OperandStack stack
           
 
Constructor Summary
Frame(int maxLocals, int maxStack)
          Constructs an empty Frame
Frame(int exceptionIndex, org.apache.bcel.generic.MethodGen mg, org.apache.bcel.generic.ConstantPoolGen cpg)
          Construct pre-initialized Frame suitable for Method invokation from an Exception.
Frame(LocalVariables locals, OperandStack stack)
          Construct a Frame from existing LocalVariables and OperandStack
Frame(org.apache.bcel.generic.MethodGen mg, org.apache.bcel.generic.ConstantPoolGen cpg)
          Construct pre-initialized Frame suitable for normal Method invokation.
Frame(org.apache.bcel.generic.MethodGen mg, org.apache.bcel.generic.ConstantPoolGen cpg, boolean exceptionEntry)
          Construct pre-initialized Frame suitable for various Method invokation entry points.
 
Method Summary
protected  java.lang.Object clone()
           
static org.apache.bcel.classfile.StackMapType convertSignature2StackMapType(java.lang.String signature, org.apache.bcel.generic.ConstantPoolGen cpg)
           
static org.apache.bcel.classfile.StackMapType convertType2StackMapType(byte type, java.lang.String signature, org.apache.bcel.generic.ConstantPoolGen cpg)
           
static org.apache.bcel.classfile.StackMapType convertType2StackMapType(org.apache.bcel.generic.Type type, org.apache.bcel.generic.ConstantPoolGen cpg)
          Convert org.apache.bcel.generic.Type into a StackMapType.
 boolean equals(java.lang.Object o)
           
 Frame getClone()
          Returns a properly cast clone of Frame
 LocalVariables getLocals()
           
 OperandStack getStack()
           
 org.apache.bcel.classfile.StackMapEntry getStackMapEntry(int byteCodeOffset, org.apache.bcel.classfile.ConstantPool cp)
          Generate a StackMapEntry from the contents of the Frame.
private  void indent(java.lang.StringBuffer sb, java.lang.String indentString, int indentLevel)
           
 void setLocals(LocalVariables locals)
          Replace the LocalVariables stored in this frame with a copy of another set of LocalVariables.
 java.lang.String toString()
          Returns a String representation of the Frame instance.
 java.lang.String toString(java.lang.String indentString, int indentLevel)
          Returns a String representation of the Frame instance, prepending each line with the indent string.
 
Methods inherited from class java.lang.Object
, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

log

private static org.apache.log4j.Logger log

locals

private LocalVariables locals

stack

private OperandStack stack
Constructor Detail

Frame

public Frame(int maxLocals,
             int maxStack)
Constructs an empty Frame

Frame

public Frame(LocalVariables locals,
             OperandStack stack)
Construct a Frame from existing LocalVariables and OperandStack

Frame

public Frame(org.apache.bcel.generic.MethodGen mg,
             org.apache.bcel.generic.ConstantPoolGen cpg)
Construct pre-initialized Frame suitable for normal Method invokation. Uses a MethodGen and ConstantPoolGen to derive the necessary data that is to be loaded into the LocalVariables

Frame

public Frame(org.apache.bcel.generic.MethodGen mg,
             org.apache.bcel.generic.ConstantPoolGen cpg,
             boolean exceptionEntry)
Construct pre-initialized Frame suitable for various Method invokation entry points. Uses a MethodGen and ConstantPoolGen to derive the necessary data that is to be loaded into the LocalVariables
Parameters:
exceptionEntry - true when constructing a frame for an Exception entry point where it cannot be known what the LocalVariables will be until after the corresponding try-catch block has been investigated. Use false for normal method entry invokation.

Frame

public Frame(int exceptionIndex,
             org.apache.bcel.generic.MethodGen mg,
             org.apache.bcel.generic.ConstantPoolGen cpg)
Construct pre-initialized Frame suitable for Method invokation from an Exception. Use the normal method invokation constructor to derive the necessary data for the LocalVariables and an add the exception to the OperandStack
Method Detail

clone

protected java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getClone

public Frame getClone()
Returns a properly cast clone of Frame

getLocals

public LocalVariables getLocals()

setLocals

public void setLocals(LocalVariables locals)
Replace the LocalVariables stored in this frame with a copy of another set of LocalVariables. This is used by StackMapGen to replace a bogus set of LocalVariables that an exception branch target was initialized with to a valid set of LocalVariables that is calculated by the Control Flow Analysis.

getStack

public OperandStack getStack()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

convertType2StackMapType

public static org.apache.bcel.classfile.StackMapType convertType2StackMapType(org.apache.bcel.generic.Type type,
                                                                              org.apache.bcel.generic.ConstantPoolGen cpg)
Convert org.apache.bcel.generic.Type into a StackMapType. Should really be a part of the StackMap class, but that's a BCEL class, so this is the best that can be done for now.

convertSignature2StackMapType

public static org.apache.bcel.classfile.StackMapType convertSignature2StackMapType(java.lang.String signature,
                                                                                   org.apache.bcel.generic.ConstantPoolGen cpg)

convertType2StackMapType

public static org.apache.bcel.classfile.StackMapType convertType2StackMapType(byte type,
                                                                              java.lang.String signature,
                                                                              org.apache.bcel.generic.ConstantPoolGen cpg)

getStackMapEntry

public org.apache.bcel.classfile.StackMapEntry getStackMapEntry(int byteCodeOffset,
                                                                org.apache.bcel.classfile.ConstantPool cp)
Generate a StackMapEntry from the contents of the Frame.

toString

public java.lang.String toString()
Returns a String representation of the Frame instance.
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.lang.String indentString,
                                 int indentLevel)
Returns a String representation of the Frame instance, prepending each line with the indent string.
Parameters:
indentString - String to prepend to each line to allow indent matching.
indentLevel - How many copies of indent string to append.

indent

private void indent(java.lang.StringBuffer sb,
                    java.lang.String indentString,
                    int indentLevel)