Sat, 22 Dec 2018 13:10:38 -0800
Added tag jdk8u202-b25 for changeset 15d8c732039b
1 /*
2 * @test /nodynamiccopyright/
3 * @bug 8003280
4 * @summary Add lambda tests
5 * check that inner scopes are left after a lambda check exception has been thrown
6 * @compile/fail/ref=LambdaExpr19.out -XDrawDiagnostics LambdaExpr19.java
7 */
8 class LambdaExpr19 {
10 interface SAM {
11 String m();
12 }
14 void m(SAM s) { }
16 void testTry() {
17 m(() -> {
18 try { return 1; }
19 catch (Exception e) { }
20 });
21 }
23 void testTryWithResources() {
24 m(() -> {
25 try (AutoCloseable c = null) { return 1; }
26 catch (Exception e) { }
27 });
28 }
30 void testSwitch() {
31 m(() -> {
32 switch (1) {
33 default: return 1;
34 }
35 });
36 }
38 void testFor() {
39 m(() -> {
40 for (;;) {
41 return 1;
42 }
43 });
44 }
46 void testForeach() {
47 m(() -> {
48 for (Object o : new Object[] { null , null }) {
49 return 1;
50 }
51 });
52 }
53 }