Well, here's a very interesting Java 7 puzzle for JLS experts. The following code snippet will not compile with either javac or Eclipse:
package com.example; public class X { public static X com = new X(); public void x() { System.out.println(com.example.X.com);
The com member seems to completely prevent access to com.* from X However, this does not apply. The following actions, for example:
public void x() { System.out.println(com.example.X.class); }
My question (s):
- How is this behavior justified from JLS?
- How can I get around this problem.
Note that this is simply a simplification for the real problem in the generated code, where the full qualification of com.example.X is required and the com member cannot be renamed.
Update . I think it could be a similar problem like this: Why can't I "static import"? "equals" method in Java?
source share