Re: more fun with class initializers

Date view Thread view Subject view Author view

From: Archie Cobbs (archie@whistle.com)
Date: Wed Nov 18 1998 - 18:17:46 EST


Godmar Back writes:
> The fact that you on one hand are able to construct an object of a given
> class before the static initializer has finished, but on the other
> hand have to wait until it finishes before it's clear whether a class
> is "usable" leads to funny phenomena. See the test.
>
> What that means is that there's another state in which a class can
> be in: One in which it's okay to create instances via newInstance(),
> but it's not okay to access it in Java code nor is it btw okay to use
> reflection such as getField on it.
>
> A class is put in that new state before we call the static initializer.
> Now we must distinguish between operations that require the class
> completely and successfully initialized (that is, with no
> ExceptionInInitializerError), and those for which it is sufficient
> that the linking has proceeded to the state right before calling out
> to the static initializers.
>
> This seems damn confusing.

You're right.. I don't see any other way out of it..

-Archie

___________________________________________________________________________
Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:03 EDT