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 */ 9 10class BadBreakContinue { 11 12 static interface SAM { 13 void m(); 14 } 15 16 SAM s1 = ()-> { break; }; 17 SAM s2 = ()-> { continue; }; 18 SAM s3 = ()-> { 19 SAM s3_1 = ()-> { break; }; 20 SAM s3_2 = ()-> { continue; }; 21 }; 22 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 } 33 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} 45