Community
Participate
Working Groups
Build 1127 + head contents: Javac and jikes both reject this code. public class H { H(Object o) { class A { private A() {} } class B extends H { B() { super(new A() {}); } } } } We compile it. Javac 1.4.1 reports: H.java:8: cannot reference H before supertype constructor has been called super(new A() {}); ^ 1 error jikes 1.18 reports: Found 1 semantic error compiling "D:/temp/H.java": 8. super(new A() {}); ^-^ *** Semantic Error: The innermost enclosing instance of type "H" is "this", which is not yet initialized here.
I believe we would use H.this, instead of this... need to investigate.
Actually, we accept this code since we do not eagerly require an enclosing instance for local types, until actually needed. On the following example though, we are getting an internal failure which we shouldn't: public class X { public static void main(String[] arguments) { new X(null).foo(); System.out.println("DONE"); } X(Object o){ } void foo(){ class A { private A() { } } class B extends X { B() { super(new A(){ void foo() { System.out.println(X.this); } }); } } } }
Both issues fixed. We will now reject original code.
Verified.