ある名前が型名とフィールド名の両方で解釈できる場合、フィールド名としての解釈が優先される

JLS2 6.3.2, 6.5 より。

package foo;

class ObscuredName {
    Inner foo = new Inner();
    static int i = 0  ;

    int test() {
        // ObsucuredName#i ではなく、Inner2#i へのアクセスと解釈される。
        // foo.ObscuredName を解釈する際に型の名前よりも
        // フィールドの名前が優先される。
        return foo.ObscuredName.i;
    }

    public static void main(String[] args) {
        // 1を表示する。
        System.out.println((new ObscuredName()).test());
    }

    class Inner {
        Inner2 ObscuredName = new Inner2();

        class Inner2 {
            int i = 1;
        }
    }
}