private boolean insertBreak(RegionStack stack, BlockNode loopExit, Edge exitEdge) { BlockNode exit = exitEdge.getTarget(); BlockNode insertBlock = null; boolean confirm = false; // process special cases if (loopExit == exit) { // try/catch at loop end BlockNode source = exitEdge.getSource(); if (source.contains(AType.CATCH_BLOCK) && source.getSuccessors().size() == 2) { BlockNode other = BlockUtils.selectOther(loopExit, source.getSuccessors()); if (other != null) { other = BlockUtils.skipSyntheticSuccessor(other); if (other.contains(AType.EXC_HANDLER)) { insertBlock = source; confirm = true; } } } } if (!confirm) { while (exit != null) { if (insertBlock != null && isPathExists(loopExit, exit)) { // found cross if (canInsertBreak(insertBlock)) { confirm = true; break; } return false; } insertBlock = exit; List<BlockNode> cs = exit.getCleanSuccessors(); exit = cs.size() == 1 ? cs.get(0) : null; } } if (!confirm) { return false; } InsnNode breakInsn = new InsnNode(InsnType.BREAK, 0); insertBlock.getInstructions().add(breakInsn); stack.addExit(exit); // add label to 'break' if needed addBreakLabel(exitEdge, exit, breakInsn); return true; }