public static List<ExceptionHandler> run(final InstructionCollection instructions, final List<ExceptionTableEntry> tableEntries) {
VerifyArgument.notNull(instructions, "instructions");
VerifyArgument.notNull(tableEntries, "tableEntries");
final ExceptionHandlerMapper builder = new ExceptionHandlerMapper(instructions, tableEntries);
final ControlFlowGraph cfg = builder.build();
final List<ExceptionHandler> handlers = new ArrayList<>();
final Map<ExceptionTableEntry, ControlFlowNode> handlerStartNodes = new IdentityHashMap<>();
for (final ExceptionTableEntry entry : builder._tableEntries) {
final Instruction handlerStart = instructions.atOffset(entry.getHandlerOffset());
final ControlFlowNode handlerStartNode = builder.findNode(handlerStart);
if (handlerStartNode == null) {
throw new IllegalStateException(
format(
"Could not find entry node for handler at offset %d.",
handlerStart.getOffset()
)
);
}
if (handlerStartNode.getIncoming().isEmpty()) {
builder.createEdge(cfg.getEntryPoint(), handlerStartNode, JumpType.Normal);
}
handlerStartNodes.put(entry, handlerStartNode);
}
cfg.computeDominance();
cfg.computeDominanceFrontier();
for (final ExceptionTableEntry entry : builder._tableEntries) {
final ControlFlowNode handlerStart = handlerStartNodes.get(entry);
final List<ControlFlowNode> dominatedNodes = new ArrayList<>();