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.


[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index] [Subject Index] [Author Index] [Thread Index]

Re: class initialisation



> 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?

The compiler and run-time call _Jv_InitClass in appropriate places.

Specifically, each non-private static method calls the library routine
_Jv_InitClass before it does naything else.  Each "new" also
calls _Jv_InitClass.  And the compiler inserts a call to _Jv_InitClass
before a reference to a static field (unless the referenced class
is the current class or one of its superclasses).

If you think about it, I believe you will agree that handles the
required semantics.

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner