aoqi@0: /* aoqi@0: * @test /nodynamiccopyright/ aoqi@0: * @bug 8003280 aoqi@0: * @summary Add lambda tests aoqi@0: * check that inner scopes are left after a lambda check exception has been thrown aoqi@0: * @compile/fail/ref=LambdaExpr19.out -XDrawDiagnostics LambdaExpr19.java aoqi@0: */ aoqi@0: class LambdaExpr19 { aoqi@0: aoqi@0: interface SAM { aoqi@0: String m(); aoqi@0: } aoqi@0: aoqi@0: void m(SAM s) { } aoqi@0: aoqi@0: void testTry() { aoqi@0: m(() -> { aoqi@0: try { return 1; } aoqi@0: catch (Exception e) { } aoqi@0: }); aoqi@0: } aoqi@0: aoqi@0: void testTryWithResources() { aoqi@0: m(() -> { aoqi@0: try (AutoCloseable c = null) { return 1; } aoqi@0: catch (Exception e) { } aoqi@0: }); aoqi@0: } aoqi@0: aoqi@0: void testSwitch() { aoqi@0: m(() -> { aoqi@0: switch (1) { aoqi@0: default: return 1; aoqi@0: } aoqi@0: }); aoqi@0: } aoqi@0: aoqi@0: void testFor() { aoqi@0: m(() -> { aoqi@0: for (;;) { aoqi@0: return 1; aoqi@0: } aoqi@0: }); aoqi@0: } aoqi@0: aoqi@0: void testForeach() { aoqi@0: m(() -> { aoqi@0: for (Object o : new Object[] { null , null }) { aoqi@0: return 1; aoqi@0: } aoqi@0: }); aoqi@0: } aoqi@0: }