This code won’t compile because there is an illegal reference to a static field.
public enum Foo {
A,
B;
private Foo[] foos = new Foo[] { Foo.A };
}
Shouldn’t you be able to access static fields from a non-static field initializer? For example:
public class Foo {
static int A;
private int[] foos = new int[] { Foo.A };
}
This compiles fine.
Note, making foos static in the first example compiles.
Check out Java Language Specification, Third Edition, Section 8.9 at http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.9
Discussion