Statement (Statement head) { if (head.getLastBasicType() != StatementType.GENERAL) { return null; } Set<Statement> setHandlers = DecHelper.getUniquePredExceptions(head); if (!setHandlers.isEmpty()) { int hnextcount = 0; // either no statements with connection to next, or more than 1 Statement next = null; List<StatEdge> lstHeadSuccs = head.getSuccessorEdges(EdgeType.DIRECT_ALL); if (!lstHeadSuccs.isEmpty() && lstHeadSuccs.get(0).getType() == EdgeType.REGULAR) { next = lstHeadSuccs.get(0).getDestination(); hnextcount = 2; } for (StatEdge edge : head.getSuccessorEdges(EdgeType.EXCEPTION)) { Statement stat = edge.getDestination(); boolean handlerok = true; if (edge.getExceptions() != null && setHandlers.contains(stat)) { if (stat.getLastBasicType() != StatementType.GENERAL) { handlerok = false; } else { List<StatEdge> lstStatSuccs = stat.getSuccessorEdges(EdgeType.DIRECT_ALL); if (!lstStatSuccs.isEmpty() && lstStatSuccs.get(0).getType() == EdgeType.REGULAR) { Statement statn = lstStatSuccs.get(0).getDestination(); if (next == null) { next = statn; } else if (next != statn) { handlerok = false; } if (handlerok) { hnextcount++; } } } } else { handlerok = false; } if (!handlerok) { setHandlers.remove(stat); } } if (hnextcount != 1 && !setHandlers.isEmpty()) { List<Statement> lst = new ArrayList<>(); lst.add(head); lst.addAll(setHandlers); for (Statement st : lst) { if (st.isMonitorEnter()) { return null; } } if (DecHelper.checkStatementExceptions(lst)) { return new CatchStatement(head, next, setHandlers); } } } return null; }