{
//Do some preparation for each trap in the method
for (Iterator<Trap> trapIt = body.getTraps().iterator(); trapIt.hasNext(); )
{
Trap trap = trapIt.next();
/**
* Find the real header of this handler block
*
*/
Unit handler = trap.getHandlerUnit();
Unit pred = handler;
while(this.unitToPreds.get(pred).size() > 0)
pred = this.unitToPreds.get(pred).get(0);
handler2header.put(handler, pred);
/***********/
/*
* Keep this here for possible future changes.
*/
/*GuardedBlock gb = new GuardedBlock(trap.getBeginUnit(), trap.getEndUnit());
Unit ehnop;
if(try2nop.containsKey(gb))
ehnop = try2nop.get(gb);
else
{
ehnop = new EHNopStmt();
try2nop.put(gb, ehnop);
}*/
Unit ehnop;
if(try2nop.containsKey(trap.getBeginUnit()))
ehnop = try2nop.get(trap.getBeginUnit());
else
{
ehnop = new EHNopStmt();
try2nop.put(trap.getBeginUnit(), ehnop);
}
}
//Only add a nop once
Hashtable<Unit, Boolean> nop2added = new Hashtable<Unit, Boolean>();
// Now actually add the edge
AddExceptionalEdge:
for (Iterator<Trap> trapIt = body.getTraps().iterator(); trapIt.hasNext(); )
{
Trap trap = trapIt.next();
Unit b = trap.getBeginUnit();
Unit handler = trap.getHandlerUnit();
handler = handler2header.get(handler);
/**
* Check if this trap is a finally trap that handles exceptions of an adjacent catch block;