Package 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, that is, 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, for example 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(), that is, there is no difference semantically.- See Also:
MethodGen,CodeException,InstructionHandle
-
-
Field Summary
Fields Modifier and Type Field Description private ObjectTypecatchType(package private) static CodeExceptionGen[]EMPTY_ARRAYprivate InstructionHandleendPcprivate InstructionHandlehandlerPcprivate InstructionHandlestartPc
-
Constructor Summary
Constructors Constructor Description CodeExceptionGen(InstructionHandle startPc, InstructionHandle endPc, InstructionHandle handlerPc, ObjectType catchType)Add an exception handler, that is, specify region where a handler is active and an instruction where the actual handling is done.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()booleancontainsTarget(InstructionHandle ih)Tests whether this targeter targets the specified instruction handle.ObjectTypegetCatchType()Gets the type of the Exception to catch, 'null' for ANY.CodeExceptiongetCodeException(ConstantPoolGen cp)Gets CodeException object.InstructionHandlegetEndPC()Gets the end of handled region (inclusive).InstructionHandlegetHandlerPC()Gets the start of handler.InstructionHandlegetStartPC()Gets the start of handled region (inclusive).voidsetCatchType(ObjectType catchType)Sets the type of the Exception to catch.voidsetEndPC(InstructionHandle endPc)Sets end of handler.voidsetHandlerPC(InstructionHandle handlerPc)Sets handler code.voidsetStartPC(InstructionHandle startPc)Sets start of handler.java.lang.StringtoString()voidupdateTarget(InstructionHandle oldIh, InstructionHandle newIh)Replaces the target of this targeter from this old handle to the new handle.
-
-
-
Field Detail
-
EMPTY_ARRAY
static final CodeExceptionGen[] EMPTY_ARRAY
-
startPc
private InstructionHandle startPc
-
endPc
private InstructionHandle endPc
-
handlerPc
private InstructionHandle handlerPc
-
catchType
private ObjectType catchType
-
-
Constructor Detail
-
CodeExceptionGen
public CodeExceptionGen(InstructionHandle startPc, InstructionHandle endPc, InstructionHandle handlerPc, ObjectType catchType)
Add an exception handler, that is, specify region where a handler is active and an instruction where the actual handling is done.- Parameters:
startPc- Start of handled region (inclusive).endPc- End of handled region (inclusive).handlerPc- Where handling is done.catchType- which exception is handled, null for ANY.
-
-
Method Detail
-
clone
public java.lang.Object clone()
- Overrides:
clonein classjava.lang.Object
-
containsTarget
public boolean containsTarget(InstructionHandle ih)
Description copied from interface:InstructionTargeterTests whether this targeter targets the specified instruction handle.- Specified by:
containsTargetin interfaceInstructionTargeter- Parameters:
ih- the instruction handle to test.- Returns:
- true, if ih is target of this handler.
-
getCatchType
public ObjectType getCatchType()
Gets the type of the Exception to catch, 'null' for ANY.- Returns:
- the type of the Exception to catch, 'null' for ANY.
-
getCodeException
public CodeException getCodeException(ConstantPoolGen cp)
Gets CodeException object. This relies on that the instruction list has already been dumped to byte code or that the 'setPositions' methods has been called for the instruction list.- Parameters:
cp- constant pool.- Returns:
- the CodeException object.
-
getEndPC
public InstructionHandle getEndPC()
Gets the end of handled region (inclusive).- Returns:
- end of handled region (inclusive).
-
getHandlerPC
public InstructionHandle getHandlerPC()
Gets the start of handler.- Returns:
- start of handler.
-
getStartPC
public InstructionHandle getStartPC()
Gets the start of handled region (inclusive).- Returns:
- start of handled region (inclusive).
-
setCatchType
public void setCatchType(ObjectType catchType)
Sets the type of the Exception to catch. Set 'null' for ANY.- Parameters:
catchType- the type of the Exception to catch.
-
setEndPC
public void setEndPC(InstructionHandle endPc)
Sets end of handler.- Parameters:
endPc- End of handled region (inclusive).
-
setHandlerPC
public void setHandlerPC(InstructionHandle handlerPc)
Sets handler code.- Parameters:
handlerPc- Start of handler.
-
setStartPC
public void setStartPC(InstructionHandle startPc)
Sets start of handler.- Parameters:
startPc- Start of handled region (inclusive).
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
updateTarget
public void updateTarget(InstructionHandle oldIh, InstructionHandle newIh)
Description copied from interface:InstructionTargeterReplaces the target of this targeter from this old handle to the new handle.- Specified by:
updateTargetin interfaceInstructionTargeter- Parameters:
oldIh- old target, either start or end.newIh- new target.
-
-