According to the Java Language Specification (JLS), §12.4, "Initialization of Classes and Interfaces" [JLS 2005]:
Initialization of a class consists of executing its
static
initializers and the initializers forstatic
fields (class variables) declared in the class.
...
The JLS also states in §8.3.2.1, "Initializers for Class Variables" [JLS 2005]
At run time,
static
variables that arefinal
and that are initialized with compile-time constant values are initialized first.
...
Step 3 of the detailed initialized procedure described in JLS §12.4.2 [JLS 2014] permits implementations to ignore the possibility of such recursive initialization cycles.
...
DCL14-CPP. Avoid assumptions about the initialization order between translation units | |
Initialization of variables [LAV] |
Bibliography
...
Rule 01: Declarations and Initialization (DCL) Rule 01: Declarations and Initialization (DCL)