Open srikanth-sankaran opened 2 days ago
14.15 The break Statement:
...
A break statement with no label attempts to transfer control to the innermost enclosing switch, while, do, or for statement; this enclosing statement, which is called the break target, then immediately completes normally.
...
It is a compile-time error if the break target contains any method, constructor, instance initializer, static initializer, lambda expression, or switch expression that encloses the break statement. That is, there are no non-local jumps.
Emphasis mine. This seems to suggest ECJ is correct and javac is defective.
@jarthana @stephan-herrmann - FYI
Found through code inspection and white box testing:
This program is rejected by ECJ (from at least since 4.20 days till date) but accepted by javac:
The behavior implemented by ECJ is that a
break
cannot transcend a switch expression while ayield
can transcend a switch statement. But javac seems to allow a break to transcend a switch expression.