Why doesn't this code compile?
public class A {
public class B extends A {
public B(A a) { }
}
void foo() {
A a = new A();
new B(a) { };
}
}
A.java:[7,17] cannot reference this before supertype constructor has been called
Compilation is successful if either of these changes are made:
Bis private instead of public- line 7 reads
new B(A);instead ofnew B(A) { }
Using javac version: 1.6.0_20