On Sep 22, 2006, at 7:32 PM, Gregory Shimansky wrote:

On Friday 22 September 2006 22:39 Geir Magnusson Jr. wrote:
First, thanks so much for the fast response and good solution.

I don't see any problem with this patch, but you're right - I don't
understand why we have it, since Logger should set it's "global"
field to getLogger("global") in the static initialization.

Static initialization doesn't guarantee that the field is initialized when you
need it.
I've seen it several times in classlib initialization. It happens
because <clinit> method is called only once in the stack of the calling methods (or there could be infinite recursion). If <clinit> is somewhere up the stack it won't be called again. But if some field of the class which is executing <clinit> up the stack already is needed down the stack by some other called classes' methods (called from the up the stack <clinit>), it may
be still uninitialized.

Hm.

LogManger's initializer does

  Logger root = Logger.getLogger("");

and Logger has

  public final static Logger global = Logger.getLogger("global");

which eventually executes

   LogManager man = LogManager.getLogManager();

and around we go.

So why don't we always run aground with this? Why is this the first time we see this?


I could write a real java test to show that this is possible but this is too
late at night and I can't think straight. Just trust my word :)

I think such conditions can happen not only on classlib initialization.

--
Gregory Shimansky, Intel Middleware Products Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to