188.8.131.52 Restrictions on the use of Fields during Initialization The declaration of a member needs to appear before it is used only if the member is an instance (respectively static) field of a class or interface C and all of the following conditions hold: The usage occurs in an instance (respectively static) variable initializer of C or in an instance (respectively static) initializer of C. The usage is not on the left hand side of an assignment. C is the innermost class or interface enclosing the usage. A compile-time error occurs if any of the three requirements above are not met.
However the following code does not compile using Sun's javac compiler (1.4.0):
In fact there is a specific example in the JLS that shows the above code to be legal - see the first line of the static intializer in the section referenced above where x = 10; is used before x is declared. What's happening?