net.sf.jode.flow
Class TryBlock

java.lang.Object
  extended by net.sf.jode.flow.StructuredBlock
      extended by net.sf.jode.flow.TryBlock

public class TryBlock
extends StructuredBlock

A TryBlock is created for each exception in the ExceptionHandlers attribute.
For each catch block (there may be more than one catch block appending a single try block) and for each finally and each synchronized block such a TryBlock is created. The finally/synchronized-blocks have a null exception type so that they are easily distinguishable from the catch blocks.
A TryBlock may be converted later into a SynchronizedBlock.

Author:
Jochen Hoenicke
See Also:
CatchBlock, FinallyBlock, SynchronizedBlock

Constructor Summary
TryBlock(FlowBlock tryFlow)
           
 
Method Summary
 void addCatchBlock(StructuredBlock catchBlock)
           
 boolean checkJikesArrayClone()
          A special transformation for try blocks: jikes generate try/catch-blocks for array clone:
 boolean doTransformations()
          Do simple transformation on the structuredBlock.
 void dumpInstruction(TabbedPrintWriter writer)
          Print the instruction expressing this structured block.
 StructuredBlock[] getSubBlocks()
          Returns all sub block of this structured block.
 boolean jumpMayBeChanged()
          Determines if there is a sub block, that flows through to the end of this block.
 VariableStack mapStackToLocal(VariableStack stack)
          This does take the instr into account and modifies stack accordingly.
 boolean replaceSubBlock(StructuredBlock oldBlock, StructuredBlock newBlock)
          Replaces the given sub block with a new block.
 
Methods inherited from class net.sf.jode.flow.StructuredBlock
appendBlock, checkConsistent, contains, copyJump, dumpSource, fillInGenSet, flowMayBeChanged, getBCELInstructions, getBytecodeInstructions, getDeclarables, getNextBlock, getNextBlock, getNextFlowBlock, getNextFlowBlock, isEmpty, isSingleExit, makeDeclaration, moveJump, needsBraces, prependBlock, propagateUsage, removeBlock, removeJump, removeOnetimeLocals, removePush, replace, setFlowBlock, setJump, setSuccessors, simplify, swapJump, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TryBlock

public TryBlock(FlowBlock tryFlow)
Method Detail

addCatchBlock

public void addCatchBlock(StructuredBlock catchBlock)

replaceSubBlock

public boolean replaceSubBlock(StructuredBlock oldBlock,
                               StructuredBlock newBlock)
Replaces the given sub block with a new block.

Overrides:
replaceSubBlock in class StructuredBlock
Parameters:
oldBlock - the old sub block.
newBlock - the new sub block.
Returns:
false, if oldBlock wasn't a direct sub block.

getSubBlocks

public StructuredBlock[] getSubBlocks()
Returns all sub block of this structured block.

Overrides:
getSubBlocks in class StructuredBlock

mapStackToLocal

public VariableStack mapStackToLocal(VariableStack stack)
This does take the instr into account and modifies stack accordingly. It then calls super.mapStackToLocal.

Overrides:
mapStackToLocal in class StructuredBlock
Parameters:
stack - the stack before the instruction is called
Returns:
stack the stack afterwards.

dumpInstruction

public void dumpInstruction(TabbedPrintWriter writer)
                     throws IOException
Description copied from class: StructuredBlock
Print the instruction expressing this structured block.

Specified by:
dumpInstruction in class StructuredBlock
Parameters:
writer - The tabbed print writer, where we print to.
Throws:
IOException

jumpMayBeChanged

public boolean jumpMayBeChanged()
Determines if there is a sub block, that flows through to the end of this block. If this returns true, you know that jump is null.

Overrides:
jumpMayBeChanged in class StructuredBlock
Returns:
true, if the jump may be safely changed.

checkJikesArrayClone

public boolean checkJikesArrayClone()
A special transformation for try blocks: jikes generate try/catch-blocks for array clone:
 try {
     PUSH ARRAY.clone()
 } catch (CloneNotSupportedException ex) {
     throw new InternalError(ex.getMessage());
 }
 
which is simply transformed to the content of the try block.


doTransformations

public boolean doTransformations()
Description copied from class: StructuredBlock
Do simple transformation on the structuredBlock.

Overrides:
doTransformations in class StructuredBlock
Returns:
true, if some transformation was done.