Community
Participate
Working Groups
Build 2.1M2 The following code is rejected by the compiler complaining against the enclosing instance of anonymous subclass of X1. Javac accepts this code as expected. ======= public class X { public static void main(String[] arguments) { new X().new X2().foo(); } class X1 { void baz1() { System.out.println("X1.baz1()"); } } class X2 { void foo(){ X.this.new X1(){ void bar(){ baz(); baz1(); baz2(); } }.bar(); } void baz2() { System.out.println("X2.baz2()"); } } void baz() { System.out.println("X.baz()"); } }
Problem was that enclosing instance was only allowed as first synthetic argument, where it could be anywhere amongst synthetic arguments. Fixed
Verified.