JDK-6845426 : non-static method with no args is called during the class initialization process
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 6,7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-05-27
  • Updated: 2011-04-25
  • Resolved: 2011-04-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 Other
7Fixed hs21Fixed
Description
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.

Comments
EVALUATION Please note that for backward compatibility reasons, the new behavior of requiring an ACC_STATIC modifier for <clinit> methods will only occur for classfiles with classfile version >= 51.
07-03-2011

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-rt/hotspot/rev/dbad0519a1c4
05-03-2011