test/tools/javac/lambda/LambdaExpr19.java

changeset 0
959103a6100f
equal deleted inserted replaced
-1:000000000000 0:959103a6100f
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 {
9
10 interface SAM {
11 String m();
12 }
13
14 void m(SAM s) { }
15
16 void testTry() {
17 m(() -> {
18 try { return 1; }
19 catch (Exception e) { }
20 });
21 }
22
23 void testTryWithResources() {
24 m(() -> {
25 try (AutoCloseable c = null) { return 1; }
26 catch (Exception e) { }
27 });
28 }
29
30 void testSwitch() {
31 m(() -> {
32 switch (1) {
33 default: return 1;
34 }
35 });
36 }
37
38 void testFor() {
39 m(() -> {
40 for (;;) {
41 return 1;
42 }
43 });
44 }
45
46 void testForeach() {
47 m(() -> {
48 for (Object o : new Object[] { null , null }) {
49 return 1;
50 }
51 });
52 }
53 }

mercurial