class initialisation

Jerry Kramskoy Jerry.Kramskoy@isltd.insignia.com
Wed Sep 16 11:46:00 GMT 1998


I have a question for Cygnus ...

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.

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?

Jerry Kramskoy, Senior Consultant, Embedded VM Group
Insignia Solutions.




More information about the Java mailing list