void (ControlFlowGraph graph) { CancellationManager cancellationManager = DecompilerContext.getCancellationManager(); List<Range> lstRanges = new ArrayList<>(); // aggregate ranges for (ExceptionRangeCFG range : graph.getExceptions()) { boolean found = false; for (Range arr : lstRanges) { if (arr.handler == range.getHandler() && Objects.equals(range.getUniqueExceptionsString(), arr.uniqueStr)) { arr.protectedRange.addAll(range.getProtectedRange()); found = true; break; } } if (!found) { // doesn't matter, which range chosen lstRanges.add(new Range(range.getHandler(), range.getUniqueExceptionsString(), new HashSet<>(range.getProtectedRange()), range)); } } // process aggregated ranges for (Range range : lstRanges) { if (range.uniqueStr != null) { BasicBlock handler = range.handler; InstructionSequence seq = handler.getSeq(); Instruction firstinstr; if (!seq.isEmpty()) { firstinstr = seq.getInstr(0); if (firstinstr.opcode == CodeConstants.opc_pop || firstinstr.opcode == CodeConstants.opc_astore) { Set<BasicBlock> setrange = new HashSet<>(range.protectedRange); for (Range range_super : lstRanges) { // finally or strict superset cancellationManager.checkCanceled(); if (range != range_super) { Set<BasicBlock> setrange_super = new HashSet<>(range_super.protectedRange); if (!setrange.contains(range_super.handler) && !setrange_super.contains(handler) && (range_super.uniqueStr == null || setrange_super.containsAll(setrange))) { if (range_super.uniqueStr == null) { setrange_super.retainAll(setrange); } else { setrange_super.removeAll(setrange); } if (!setrange_super.isEmpty()) { BasicBlock newBlock = handler; // split the handler if (seq.length() > 1) { InstructionSequence newSeq = new SimpleInstructionSequence(); newSeq.addInstruction(firstinstr.clone(), -1); newBlock = new BasicBlock(++graph.last_id, newSeq); graph.getBlocks().addWithKey(newBlock, newBlock.id); List<BasicBlock> lstTemp = new ArrayList<>(); lstTemp.addAll(handler.getPredecessors()); lstTemp.addAll(handler.getPredecessorExceptions()); // replace predecessors for (BasicBlock pred : lstTemp) { pred.replaceSuccessor(handler, newBlock); } // replace handler for (ExceptionRangeCFG range_ext : graph.getExceptions()) { if (range_ext.getHandler() == handler) { range_ext.setHandler(newBlock); } else if (range_ext.getProtectedRange().contains(handler)) { newBlock.addSuccessorException(range_ext.getHandler()); range_ext.getProtectedRange().add(newBlock); } } newBlock.addSuccessor(handler); if (graph.getFirst() == handler) { graph.setFirst(newBlock); } // remove the first pop in the handler seq.removeInstruction(0); } newBlock.addSuccessorException(range_super.handler); range_super.rangeCFG.getProtectedRange().add(newBlock); handler = range.rangeCFG.getHandler(); seq = handler.getSeq(); } } } } } } } } }