The compiler currently generates code for local classes, even when they appear in the "dead" branch of an if statement:
public
class DeadClass {
String msg = "test";
DeadClass() {
if (false) {
class Foo {
void method() {
System.out.println(msg);
}
}
new Foo().method();
}
}
public static void main(String[] args) {
new DeadClass();
}
}
public
class DeadClass {
String msg = "test";
DeadClass() {
if (false) {
class Foo {
void method() {
System.out.println(msg);
}
}
new Foo().method();
}
}
public static void main(String[] args) {
new DeadClass();
}
}