This is the mail archive of the java-discuss@sourceware.cygnus.com mailing list for the GCJ project. See the GCJ home page for more information.
> > Java VM semantics are very explicit about **when** a class initialiser > (<clinit>) gets executed. > [See section 2.16.4 of the book "The Java Virtual Machine Specification" by > Lindholm and Yellin] > > A <clinit> for class X can only be run at the **first active use** of a > bytecode requiring that class X, such as an invoke or a field access > involving X or a subclass of X. "Very explicit" is somewhat of an overstatement. In fact, this issue has been very fuzzy. In particular, it's not clear what the "first active use" is: for instance, is calling Class.forName() an active use? > > Therefore, there are ordering dependencies between <clinit>'s based on the > execution path taken through the Java program. > > With interpreting/dynamic compilation, this occurs naturally (assuming the > VM is correctly implemented). With static translation to host code, how > does this translation ensure the ordering dependencies for <clinit>'s are > honoured? > Good question, though. I'm looking forward to hearing Cygnus's answer. - Godmar