Package serp.bytecode
Class ExceptionHandler
java.lang.Object
serp.bytecode.ExceptionHandler
- All Implemented Interfaces:
BCEntity
,InstructionPtr
,VisitAcceptor
Represents a
try {} catch() {}
statement in bytecode.- Author:
- Abe White
-
Method Summary
Modifier and TypeMethodDescriptionvoid
acceptVisit
(BCVisitor visit) Accept a visit from aBCVisitor
, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.Return the bytecode of the exception type; returns null for catch-all clauses used to implement finally blocks.int
Return the index into the classConstantPool
of theClassEntry
describing the exception type this handler catches.Return the name of the exception type; returns null for catch-all clauses used to implement finally blocks.Return theClass
of the exception type; returns null for catch-all clauses used to implement finally blocks.Return the class loader to use when loading related classes.getCode()
Return the owning code block.Return the instruction marking the beginning of the catch {} block.int
getPool()
Return the constant pool of the current class.Return the project of the current class.Return the instruction at the end of the try {} block.int
Return the program counter end position for this exception handler.Return the instruction marking the beginning of the try {} block.int
boolean
isValid()
Return false if this entity has been removed from its parent; in this case the results of any operations on the entity are undefined.void
replaceTarget
(Instruction oldTarget, Instruction newTarget) Replace the given old, likely invalid, target with a new target.void
Set the class of the exception type, or null for catch-all clauses used for finally blocks.void
Set the class of the exception type, or null for catch-all clauses used with finally blocks.void
Set the class of the exception type, or null for catch-all clauses used for finally blocks.void
setCatchIndex
(int catchTypeIndex) Set the index into the classConstantPool
of theClassEntry
describing the exception type this handler catches.void
setHandlerStart
(int handler) void
setHandlerStart
(Instruction instruction) Set theInstruction
marking the beginning of the catch block.void
setTryEnd
(int end) void
setTryEnd
(Instruction instruction) Set the Instruction at the end of the try block.void
setTryStart
(int start) void
setTryStart
(Instruction instruction) Set theInstruction
marking the beginning of the try block.void
Use the byte indexes read from the class file to calculate and set references to the target instruction(s) for this ptr.
-
Method Details
-
getCode
Return the owning code block.- Specified by:
getCode
in interfaceInstructionPtr
-
getTryStart
Return the instruction marking the beginning of the try {} block. -
setTryStart
Set theInstruction
marking the beginning of the try block. The instruction must already be a part of the method. -
getTryEnd
Return the instruction at the end of the try {} block. -
setTryEnd
Set the Instruction at the end of the try block. The Instruction must already be a part of the method. -
getHandlerStart
Return the instruction marking the beginning of the catch {} block. -
setHandlerStart
Set theInstruction
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. -
getCatchIndex
public int getCatchIndex()Return the index into the classConstantPool
of theClassEntry
describing the exception type this handler catches. -
setCatchIndex
public void setCatchIndex(int catchTypeIndex) Set the index into the classConstantPool
of theClassEntry
describing the exception type this handler catches. -
getCatchName
Return the name of the exception type; returns null for catch-all clauses used to implement finally blocks. The name will be returned in a forum suitable for aClass.forName(java.lang.String)
call. -
getCatchType
Return theClass
of the exception type; returns null for catch-all clauses used to implement finally blocks. -
getCatchBC
Return the bytecode of the exception type; returns null for catch-all clauses used to implement finally blocks. -
setCatch
Set the class of the exception type, or null for catch-all clauses used with finally blocks. -
setCatch
Set the class of the exception type, or null for catch-all clauses used for finally blocks. -
setCatch
Set the class of the exception type, or null for catch-all clauses used for finally blocks. -
updateTargets
public void updateTargets()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 and before it is written after modification.- Specified by:
updateTargets
in interfaceInstructionPtr
-
replaceTarget
Description copied from interface:InstructionPtr
Replace the given old, likely invalid, target with a new target. The new target Instruction is guaranteed to be in the same code block as this InstructionPtr.- Specified by:
replaceTarget
in interfaceInstructionPtr
-
getProject
Description copied from interface:BCEntity
Return the project of the current class.- Specified by:
getProject
in interfaceBCEntity
-
getPool
Description copied from interface:BCEntity
Return the constant pool of the current class. -
getClassLoader
Description copied from interface:BCEntity
Return the class loader to use when loading related classes.- Specified by:
getClassLoader
in interfaceBCEntity
-
isValid
public boolean isValid()Description copied from interface:BCEntity
Return false if this entity has been removed from its parent; in this case the results of any operations on the entity are undefined. -
acceptVisit
Description copied from interface:VisitAcceptor
Accept a visit from aBCVisitor
, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.- Specified by:
acceptVisit
in interfaceVisitAcceptor
-
setTryStart
public void setTryStart(int start) -
getTryStartPc
public int getTryStartPc() -
setTryEnd
public void setTryEnd(int end) -
getTryEndPc
public int getTryEndPc()Return the program counter end position for this exception handler. This represents an index into the code byte array. -
setHandlerStart
public void setHandlerStart(int handler) -
getHandlerStartPc
public int getHandlerStartPc()
-