javac fails the jacks test 16.2.3-switch-1. The offending code is something
like
void f(int n) {
switch (n) {
case 12:
final int x;
x = 1;
class Local {
int y = x;
}
break;
case 13:
int z = new Local().y; // verify error in generated code
}
}
The problem is that the JLS allows this code, but the variable x hasn't
been assigned at the point where it is captured.
like
void f(int n) {
switch (n) {
case 12:
final int x;
x = 1;
class Local {
int y = x;
}
break;
case 13:
int z = new Local().y; // verify error in generated code
}
}
The problem is that the JLS allows this code, but the variable x hasn't
been assigned at the point where it is captured.
- duplicates
-
JDK-4725650 Restrict scope of local classes in switch-block-group
- Resolved