JVMS 2ed states the following regarding <clinit> methods: --- Excerpt-from-spec --- 3.9 Specially Named Initialization Methods A class or interface has at most one class or interface initialization method and is initialized (2.17.4) by invoking that method. The initialization method of a class or interface is static and takes no arguments. It has the special name <clinit>. This name is supplied by a compiler. Because the name <clinit> is not a valid identifier, it cannot be used directly in a program written in the Java programming language. Class and interface initialization methods are invoked implicitly by the Java virtual machine; they are never invoked directly from any Java virtual machine instruction, but are invoked only indirectly as part of the class initialization process. --- End-Of-Excerpt --- However, if a class contains non-static <clinit>()V method then the method is still called by JVM as in case of "right" static <clinit>()V method.
|