bcel API: Class CodeExceptionGen

org.apache.bcel.generic
Class CodeExceptionGen

java.lang.Object
  |
  +--org.apache.bcel.generic.CodeExceptionGen
All Implemented Interfaces:
java.lang.Cloneable, InstructionTargeter

public final class CodeExceptionGen
extends java.lang.Object
implements InstructionTargeter, java.lang.Cloneable

This class represents an exception handler, i.e., specifies the region where a handler is active and an instruction where the actual handling is done. pool as parameters. Opposed to the JVM specification the end of the handled region is set to be inclusive, i.e. all instructions between start and end are protected including the start and end instructions (handles) themselves. The end of the region is automatically mapped to be exclusive when calling getCodeException(), i.e., there is no difference semantically.

Version:
$Id: CodeExceptionGen.java,v 1.1.1.1 2001/10/29 20:00:08 jvanzyl Exp $
Author:
M. Dahm
See Also:
MethodGen, CodeException, InstructionHandle

Constructor Summary
CodeExceptionGen(InstructionHandle start_pc, InstructionHandle end_pc, InstructionHandle handler_pc, ObjectType catch_type)
          Add an exception handler, i.e., specify region where a handler is active and an instruction where the actual handling is done.
 
Method Summary
 java.lang.Object clone()
           
 boolean containsTarget(InstructionHandle ih)
           
 ObjectType getCatchType()
          Gets the type of the Exception to catch, 'null' for ANY.
 CodeException getCodeException(ConstantPoolGen cp)
          Get CodeException object.
This relies on that the instruction list has already been dumped to byte code or or that the `setPositions' methods has been called for the instruction list.
 InstructionHandle getEndPC()
           
 InstructionHandle getHandlerPC()
           
 InstructionHandle getStartPC()
           
 void setCatchType(ObjectType catch_type)
          Sets the type of the Exception to catch.
 void setEndPC(InstructionHandle end_pc)
           
 void setHandlerPC(InstructionHandle handler_pc)
           
 void setStartPC(InstructionHandle start_pc)
           
 java.lang.String toString()
           
 void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CodeExceptionGen

public CodeExceptionGen(InstructionHandle start_pc,
                        InstructionHandle end_pc,
                        InstructionHandle handler_pc,
                        ObjectType catch_type)
Add an exception handler, i.e., specify region where a handler is active and an instruction where the actual handling is done.
Parameters:
start_pc - Start of handled region (inclusive)
end_pc - End of handled region (inclusive)
handler_pc - Where handling is done
catch_type - which exception is handled, null for ANY
Method Detail

getCodeException

public CodeException getCodeException(ConstantPoolGen cp)
Get CodeException object.
This relies on that the instruction list has already been dumped to byte code or or that the `setPositions' methods has been called for the instruction list.
Parameters:
cp - constant pool

setStartPC

public void setStartPC(InstructionHandle start_pc)

setEndPC

public void setEndPC(InstructionHandle end_pc)

setHandlerPC

public void setHandlerPC(InstructionHandle handler_pc)

updateTarget

public void updateTarget(InstructionHandle old_ih,
                         InstructionHandle new_ih)
Specified by:
updateTarget in interface InstructionTargeter
Parameters:
old_ih - old target, either start or end
new_ih - new target

containsTarget

public boolean containsTarget(InstructionHandle ih)
Specified by:
containsTarget in interface InstructionTargeter
Returns:
true, if ih is target of this handler

setCatchType

public void setCatchType(ObjectType catch_type)
Sets the type of the Exception to catch. Set 'null' for ANY.

getCatchType

public ObjectType getCatchType()
Gets the type of the Exception to catch, 'null' for ANY.

getStartPC

public InstructionHandle getStartPC()
Returns:
start of handled region (inclusive)

getEndPC

public InstructionHandle getEndPC()
Returns:
end of handled region (inclusive)

getHandlerPC

public InstructionHandle getHandlerPC()
Returns:
start of handler

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

clone

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