RFR: JDK-8234922: No compilation error reported not reported for a binding variable when loop broken with label

Jan Lahoda jan.lahoda at oracle.com
Thu Nov 28 15:11:18 UTC 2019


Bug: https://bugs.openjdk.java.net/browse/JDK-8234922

The problem described there is basically:
public class PatternTest {
     public static void test(Object o) {
         do {
             break A;
         } while (!(o instanceof String v));
         System.out.println("Got: " + v);

This should not compile, as "v" should not be in scope for the 
System.out.println, but javac fails to detect the break, as the break 
breaks to a labeled statement, not to the loop. The proposed patch 
solves not only this, but also break to any statement that is not inside 
the given loop.


How does this look?


More information about the compiler-dev mailing list