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
Hi,
Bug: https://bugs.openjdk.java.net/browse/JDK-8234922
The problem described there is basically:
---
public class PatternTest {
public static void test(Object o) {
A:
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.
Webrev:
http://cr.openjdk.java.net/~jlahoda/8234922/webrev.00/
How does this look?
Thanks,
Jan
More information about the compiler-dev
mailing list