Can I call a static method from a static initializer in Java? Is the following valid and guaranteed to work as per the Java specification?
public class Foo {
private final static int bar;
private static int generateValue() {
return 123;
}
static {
bar = generateValue();
}
}
What makes me wonder is that I might expect bar to be available inside generateValue(). I know the order of static initializer blocks is important, but I hadn't heard of the order of static method declarations being significant. But are static methods made available before static initializer blocks are executed?