This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

frontend bug -- inner classes



This should not compile, yet it does. Note that x is not static, yet
main() is.

public class t {
    int x = 0;
    public static void main() {
        new Thread() {
                public void run() {
                    x = 5;
                }
            }.start();
    }
}

javac gives this error:

t.java:6: non-static variable x cannot be referenced from a static context
                    x = 5;
                    ^

  - a


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]