-
Bug
-
Resolution: Fixed
-
P2
-
6, 7
-
b05
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2208113 | 7 | Keith Mcguigan | P2 | Closed | Fixed | b135 |
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.
--- 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.
- backported by
-
JDK-2208113 non-static <clinit> method with no args is called during the class initialization process
-
- Closed
-