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 break/continue is disallowed in lambda expressions
6 * @author Maurizio Cimadamore
7 * @compile/fail/ref=BadBreakContinue.out -XDrawDiagnostics BadBreakContinue.java
8 */
10 class BadBreakContinue {
12 static interface SAM {
13 void m();
14 }
16 SAM s1 = ()-> { break; };
17 SAM s2 = ()-> { continue; };
18 SAM s3 = ()-> {
19 SAM s3_1 = ()-> { break; };
20 SAM s3_2 = ()-> { continue; };
21 };
23 void testLabelled() {
24 loop: while (true) {
25 SAM s1 = ()-> { break loop; };
26 SAM s2 = ()-> { continue loop; };
27 SAM s3 = ()-> {
28 SAM s3_1 = ()-> { break loop; };
29 SAM s3_2 = ()-> { continue loop; };
30 };
31 }
32 }
34 void testNonLabelled() {
35 while (true) {
36 SAM s1 = ()-> { break; };
37 SAM s2 = ()-> { continue; };
38 SAM s3 = ()-> {
39 SAM s3_1 = ()-> { break; };
40 SAM s3_2 = ()-> { continue; };
41 };
42 }
43 }
44 }