TechTrader Bytecode Toolkit

com.techtrader.modules.tools.bytecode
Class ExceptionHandler

java.lang.Object
  |
  +--com.techtrader.modules.tools.bytecode.ExceptionHandler

public class ExceptionHandler
extends Object
implements InstructionPtr

Represents a try {} catch() {} statement in bytecode.

Author:
Abe White

Constructor Summary
protected ExceptionHandler(Code owner)
          Protected constructor.
 
Method Summary
 void acceptVisit(BCVisitor visit)
           
protected  void copy(ExceptionHandler orig)
           
 Class getCatchType()
          Get the class of the catch() type; returns null for catch-all clauses used to implement finally blocks.
 int getCatchTypeIndex()
          Get the index into the constant pool of the ClassEntry describing the Exception type this handler catches.
 String getCatchTypeName()
          Get the class of the catch() type; returns null for catch-all clauses used to implement finally blocks.
 int getEndPc()
          Get the program counter end position for this exception handler.
 int getHandlerPc()
          Get the start of the actual exception handler code.
 Instruction getHandlerStart()
          Get the instruction marking the beginning of the catch {} block.
 int getStartPc()
          Get the program counter start position for this exception handler.
 Instruction getTryEnd()
          Get the instruction at the end of the try {} block.
 Instruction getTryStart()
          Get the instruction marking the beginning of the try {} block.
protected  void invalidate()
          Used to invalidate the handler when it is removed from the code block.
protected  void readData(DataInput in)
           
 void setCatchType(Class type)
          Set the class of the catch() type, or null for catch-all clauses used for finally blocks.
 void setCatchTypeIndex(int catchTypeIndex)
          Set the index into the constant pool of the ClassEntry describing the Exception type this handler catches.
 void setCatchTypeName(String name)
          Set the class of the catch() type, or null for catch-all clauses used with finally blocks.
 void setEndPc(int endPc)
          Set the program counter end position for this exception handler.
 void setHandlerPc(int handlerPc)
          Get the start of the actual exception handler code.
 void setHandlerStart(Instruction instruction)
          Set the Instruction marking the beginning of the catch block.
 void setMarkers(List opcodes)
          Use the byte indexes read from the .class file to calculate and set references to the target instruction(s) for this ptr.
 void setStartPc(int startPc)
          Set the program counter start position for this exception handler.
 void setTryEnd(Instruction instruction)
          Set the Instruction at the end of the try block.
 void setTryStart(Instruction instruction)
          Set the Instruction marking the beginning of the try block.
protected  void writeData(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExceptionHandler

protected ExceptionHandler(Code owner)
Protected constructor.
Method Detail

invalidate

protected void invalidate()
Used to invalidate the handler when it is removed from the code block.

getStartPc

public int getStartPc()
Get the program counter start position for this exception handler. This represents an index into the code byte array.

setStartPc

public void setStartPc(int startPc)
Set the program counter start position for this exception handler. This represents an index into the code byte array.

setTryStart

public void setTryStart(Instruction instruction)
Set the Instruction marking the beginning of the try block. The Instruction must already be a part of the method. WARNING: if this instruction is deleted, the results are undefined.

getTryStart

public Instruction getTryStart()
Get the instruction marking the beginning of the try {} block. WARNING: if this instruction is deleted, the results are undefined.

getEndPc

public int getEndPc()
Get the program counter end position for this exception handler. This represents an index into the code byte array.

setEndPc

public void setEndPc(int endPc)
Set the program counter end position for this exception handler. This represents an index into the code byte array.

setTryEnd

public void setTryEnd(Instruction instruction)
Set the Instruction at the end of the try block. The Instruction must already be a part of the method. WARNING: if this instruction is deleted, the results are undefined.

getTryEnd

public Instruction getTryEnd()
Get the instruction at the end of the try {} block. WARNING: if this instruction is deleted, the results are undefined.

getHandlerPc

public int getHandlerPc()
Get the start of the actual exception handler code. This represents an index into the code byte array.

setHandlerPc

public void setHandlerPc(int handlerPc)
Get the start of the actual exception handler code. This represents an index into the code byte array.

setHandlerStart

public void setHandlerStart(Instruction instruction)
Set the Instruction marking the beginning of the catch block. The Instruction must already be a part of the method. WARNING: if this instruction is deleted, the results are undefined.

getHandlerStart

public Instruction getHandlerStart()
Get the instruction marking the beginning of the catch {} block. WARNING: if this instruction is deleted, the results are undefined.

getCatchTypeIndex

public int getCatchTypeIndex()
Get the index into the constant pool of the ClassEntry describing the Exception type this handler catches.

setCatchTypeIndex

public void setCatchTypeIndex(int catchTypeIndex)
Set the index into the constant pool of the ClassEntry describing the Exception type this handler catches.

getCatchTypeName

public String getCatchTypeName()
Get the class of the catch() type; returns null for catch-all clauses used to implement finally blocks.

setCatchTypeName

public void setCatchTypeName(String name)
Set the class of the catch() type, or null for catch-all clauses used with finally blocks.

getCatchType

public Class getCatchType()
                   throws ClassNotFoundException
Get the class of the catch() type; returns null for catch-all clauses used to implement finally blocks.

setCatchType

public void setCatchType(Class type)
Set the class of the catch() type, or null for catch-all clauses used for finally blocks.

setMarkers

public void setMarkers(List opcodes)
Description copied from interface: InstructionPtr
Use the byte indexes read from the .class file to calculate and set references to the target instruction(s) for this ptr. This method will be called after the byte code has been read in for the first time.
Specified by:
setMarkers in interface InstructionPtr
Tags copied from interface: InstructionPtr
Parameters:
codes - the list of opcodes in the method

copy

protected void copy(ExceptionHandler orig)

readData

protected void readData(DataInput in)
                 throws IOException

writeData

protected void writeData(DataOutput out)
                  throws IOException

acceptVisit

public void acceptVisit(BCVisitor visit)

TechTrader Bytecode Toolkit