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 TypeMethodDescriptionvoidacceptVisit(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.intReturn the index into the classConstantPoolof theClassEntrydescribing 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 theClassof 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.intgetPool()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.intReturn the program counter end position for this exception handler.Return the instruction marking the beginning of the try {} block.intbooleanisValid()Return false if this entity has been removed from its parent; in this case the results of any operations on the entity are undefined.voidreplaceTarget(Instruction oldTarget, Instruction newTarget) Replace the given old, likely invalid, target with a new target.voidSet the class of the exception type, or null for catch-all clauses used for finally blocks.voidSet the class of the exception type, or null for catch-all clauses used with finally blocks.voidSet the class of the exception type, or null for catch-all clauses used for finally blocks.voidsetCatchIndex(int catchTypeIndex) Set the index into the classConstantPoolof theClassEntrydescribing the exception type this handler catches.voidsetHandlerStart(int handler) voidsetHandlerStart(Instruction instruction) Set theInstructionmarking the beginning of the catch block.voidsetTryEnd(int end) voidsetTryEnd(Instruction instruction) Set the Instruction at the end of the try block.voidsetTryStart(int start) voidsetTryStart(Instruction instruction) Set theInstructionmarking the beginning of the try block.voidUse 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:
getCodein interfaceInstructionPtr
-
getTryStart
Return the instruction marking the beginning of the try {} block. -
setTryStart
Set theInstructionmarking 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 theInstructionmarking 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 classConstantPoolof theClassEntrydescribing the exception type this handler catches. -
setCatchIndex
public void setCatchIndex(int catchTypeIndex) Set the index into the classConstantPoolof theClassEntrydescribing 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 theClassof 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:InstructionPtrUse 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:
updateTargetsin interfaceInstructionPtr
-
replaceTarget
Description copied from interface:InstructionPtrReplace 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:
replaceTargetin interfaceInstructionPtr
-
getProject
Description copied from interface:BCEntityReturn the project of the current class.- Specified by:
getProjectin interfaceBCEntity
-
getPool
Description copied from interface:BCEntityReturn the constant pool of the current class. -
getClassLoader
Description copied from interface:BCEntityReturn the class loader to use when loading related classes.- Specified by:
getClassLoaderin interfaceBCEntity
-
isValid
public boolean isValid()Description copied from interface:BCEntityReturn 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:VisitAcceptorAccept 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:
acceptVisitin 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()
-