private boolean inExceptionHandlerBlocks(BlockNode loopEnd) { if (mth.getExceptionHandlersCount() == 0) { return false; } for (ExceptionHandler eh : mth.getExceptionHandlers()) { if (eh.getBlocks().contains(loopEnd)) { return true; } } return false; }
public void processTryCatchBlocks(MethodNode mth) { Set<TryCatchBlock> tcs = new HashSet<TryCatchBlock>(); for (ExceptionHandler handler : mth.getExceptionHandlers()) { tcs.add(handler.getTryBlock()); } for (TryCatchBlock tc : tcs) { List<BlockNode> blocks = new ArrayList<BlockNode>(tc.getHandlersCount()); Set<BlockNode> splitters = new HashSet<BlockNode>(); for (ExceptionHandler handler : tc.getHandlers()) { BlockNode handlerBlock = handler.getHandlerBlock(); if (handlerBlock != null) { blocks.add(handlerBlock); splitters.addAll(handlerBlock.getPredecessors()); } else { LOG.debug(ErrorsCounter.formatErrorMsg(mth, "No exception handler block: " + handler)); } } Set<BlockNode> exits = new HashSet<BlockNode>(); for (BlockNode splitter : splitters) { for (BlockNode handler : blocks) { List<BlockNode> s = splitter.getSuccessors(); if (s.isEmpty()) { LOG.debug(ErrorsCounter.formatErrorMsg(mth, "No successors for splitter: " + splitter)); continue; } BlockNode ss = s.get(0); BlockNode cross = BlockUtils.getPathCross(mth, ss, handler); if (cross != null && cross != ss && cross != handler) { exits.add(cross); } } } for (ExceptionHandler handler : tc.getHandlers()) { processExcHandler(handler, exits); } } }