[BUG] cicular dependencies between Toolkit & Defaults during class initialization.

Pascal Bourguignon pjb at imaginet.fr
Thu Aug 6 04:01:40 PDT 1998


There is some cicular dependencies that can appear while initializing.

When starting FreeBuilder, we get:
	
java.lang.NullPointerException
        at java/awt/Color.<init>(50)
========>	nativeValue = Toolkit.clrGetPixelValue( rgbValue);

        at java/awt/Color.<clinit>(18)

        at java/awt/Defaults.<clinit>(51)
========>	static Color WndForeground = Color.black;

        at java/awt/Toolkit.<clinit>(45)
========>  	tlkInit( tkName);

        at java/awt/Component.getToolkit(328)
        at org/freebuilder/system/classes/ResMan.loadImage(51)
        at org/freebuilder/system/classes/ResMan.<init>(38)
        at org/freebuilder/system/ideengine/IdeEngine.<init>(61)
        at org/freebuilder/Main.<init>(34)
        at org/freebuilder/Main.main(46)

So, in Toolkit, we're at the begining of the static initialization of the  
class, and although there  is a comment some lines below stating that:
	// we should refer to Defaults as late as possible (since it may
	// directly or indirectly refer to Toolkit.singleton)
the Defaults class is initialized anyway.
(What I don't understand is why Defaults class is not initialized even  
before starting the initialization of the Toolkit class since there is this  
dependency, is it a bug/feature of Java, or is it a bug of the compiler, or  
is it a bug of the virtual machine?)

Anyway, I have kludge patches to initialize the colorMaps and be able to let  
the Defaults class initialize its Color statics, and to initialize the  
toolkit singleton even before the static initialization of the Toolkit class  
is completed, if you want them, but the bug remains...

__Pascal Bourguignon__



More information about the kaffe mailing list