1 /** 2 * @test /nodynamiccopyright/ 3 * @bug 8206986 4 * @compile/fail/ref=ExpressionSwitchBreaks2.out -XDrawDiagnostics --enable-preview -source 12 ExpressionSwitchBreaks2.java 5 */ 6 7 public class ExpressionSwitchBreaks2 { 8 private String print(int i, int j) { 9 LOOP: while (true) { 10 OUTER: switch (i) { 11 case 0: 12 return switch (j) { 13 case 0: 14 break "0-0"; 15 case 1: 16 break ; //error: missing value 17 case 2: 18 break OUTER; //error: jumping outside of the switch expression 19 case 3: { 20 int x = -1; 21 x: switch (i + j) { 22 case 0: break x; //error: cannot disambiguate, wrong type as well 23 } 24 break "X"; 25 } 26 case 4: return "X"; //error: no returns from inside of the switch expression 27 case 5: continue; //error: no continue out of the switch expression 28 case 6: continue LOOP; //error: dtto, but with a label 29 case 7: continue UNKNOWN; //error: unknown label 30 default: { 31 String x = "X"; 32 x: switch (i + j) { 33 case 0: break ""; //error: cannot break from switch expression that is not immediatelly enclosing 34 } 35 break "X"; 36 } 37 }; 38 case 1: 39 break "1" + undef; //error: complex value and no switch expression 40 } 41 } 42 j: print(switch (i) { 43 default: break j; //error: "j" is ambiguous (expression/label) 44 }, 0); 45 j2: print(switch (i) { 46 default: break j2; 47 }, 0); 48 return null; 49 } 50 51 }