@Test void try_statement() { CFG cfg = buildCFG("void fun() {try {System.out.println('c');} finally { System.out.println('c'); }}"); CFGChecker cfgChecker = checker( block( element(Tree.Kind.TRY_STATEMENT) ).successors(2), block( element(Tree.Kind.IDENTIFIER, "System"), element(Tree.Kind.MEMBER_SELECT), element(Tree.Kind.CHAR_LITERAL, "'c'"), element(Tree.Kind.METHOD_INVOCATION) ).successors(1).exceptions(1), block( element(Tree.Kind.IDENTIFIER, "System"), element(Tree.Kind.MEMBER_SELECT), element(Tree.Kind.CHAR_LITERAL, "'c'"), element(Tree.Kind.METHOD_INVOCATION) ).successors(0).isFinallyBlock()); cfgChecker.check(cfg); cfg = buildCFG("void fun() {try {System.out.println('c');} catch(IllegalArgumentException e) { foo('i');} catch(Exception e){bar('e');}" + " finally { System.out.println(\"finally\"); }}"); cfgChecker = checker( block( element(Tree.Kind.TRY_STATEMENT) ).successors(4), block( element(Tree.Kind.IDENTIFIER, "System"), element(Tree.Kind.MEMBER_SELECT), element(Tree.Kind.CHAR_LITERAL, "'c'"), element(Tree.Kind.METHOD_INVOCATION) ).successors(1).exceptions(1, 2, 3), block( element(Kind.VARIABLE, "e"), element(Tree.Kind.IDENTIFIER, "foo"), element(Tree.Kind.CHAR_LITERAL, "'i'"), element(Tree.Kind.METHOD_INVOCATION) ).successors(1).exceptions(1).isCatchBlock(), block( element(Kind.VARIABLE, "e"), element(Tree.Kind.IDENTIFIER, "bar"), element(Tree.Kind.CHAR_LITERAL, "'e'"), element(Tree.Kind.METHOD_INVOCATION) ).successors(1).exceptions(1).isCatchBlock(), block( element(Tree.Kind.IDENTIFIER, "System"), element(Tree.Kind.MEMBER_SELECT), element(Kind.STRING_LITERAL, "finally"), element(Tree.Kind.METHOD_INVOCATION) ).successors(0).isFinallyBlock() ); cfgChecker.check(cfg); cfg = buildCFG( " private void f() {\n" + " try {\n" + " } catch (Exception e) {\n" + " if (e instanceof IOException) { \n" + " }\n}}"); cfgChecker = checker( block( element(Tree.Kind.TRY_STATEMENT) ).successors(0), block( element(Kind.VARIABLE, "e"), element(Tree.Kind.IDENTIFIER, "e"), element(Tree.Kind.INSTANCE_OF) ).terminator(Tree.Kind.IF_STATEMENT).ifTrue(0).ifFalse(0).isCatchBlock() ); cfgChecker.check(cfg); cfg = buildCFG( " private void f() {\n" + " try {\n" + " return;" + "} finally { foo();} bar(); }"); cfgChecker = checker( block( element(Tree.Kind.TRY_STATEMENT) ).successors(3), terminator(Kind.RETURN_STATEMENT).successors(2).exit(2).successorWithoutJump(2), block( element(Tree.Kind.IDENTIFIER, "foo"), element(Kind.METHOD_INVOCATION) ).successors(0, 1).exit(0).isFinallyBlock(), block( element(Tree.Kind.IDENTIFIER, "bar"), element(Kind.METHOD_INVOCATION) ).successors(0) ); cfgChecker.check(cfg); }
public static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak) { return new CFG(trees, null, ignoreBreak); }
CFG implements ControlFlowGraph { public static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak) { return new CFG(trees, null, ignoreBreak); } }
CFG implements ControlFlowGraph { public static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak) { return new CFG(trees, null, ignoreBreak); } private  CFG(List<? extends Tree> trees, @Nullable Symbol.MethodSymbol symbol, boolean ignoreBreakAndContinue); }
CFG implements ControlFlowGraph { public static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak) { return new CFG(trees, null, ignoreBreak); } private  CFG(List<? extends Tree> trees, @Nullable Symbol.MethodSymbol symbol, boolean ignoreBreakAndContinue); @Override Block exitBlock(); @Nullable Symbol.MethodSymbol methodSymbol(); @Override Block entryBlock(); @Override List<Block> blocks(); List<Block> reversedBlocks(); static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak); static CFG buildCFG(List<? extends Tree> trees); static CFG build(MethodTree tree); void setMethodSymbol(Symbol.MethodSymbol methodSymbol); }
CFG implements ControlFlowGraph { public static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak) { return new CFG(trees, null, ignoreBreak); } private  CFG(List<? extends Tree> trees, @Nullable Symbol.MethodSymbol symbol, boolean ignoreBreakAndContinue); @Override Block exitBlock(); @Nullable Symbol.MethodSymbol methodSymbol(); @Override Block entryBlock(); @Override List<Block> blocks(); List<Block> reversedBlocks(); static CFG buildCFG(List<? extends Tree> trees, boolean ignoreBreak); static CFG buildCFG(List<? extends Tree> trees); static CFG build(MethodTree tree); void setMethodSymbol(Symbol.MethodSymbol methodSymbol);  }