On Thu, 16 Dec 1999, John Keiser wrote:
> > From: Vojta Filip [mailto:[EMAIL PROTECTED]]
> >
> > And the second problem - internal Strings. I have method intern()
> > implemented in VM (native), because I want the behavior of java 1.2 -
> > static strings are interned. I have my internal hash table and I can put
> > any static string when one is created (but with Classpath I must call
> > intern() or do intern native and use my internal hashtable).
> >
>
> Is there trouble calling intern()? Is it going to be more efficient to do
> it in the VM instead? I hesitate to make it a VM thing if there is not a
> real benefit to doing it. Adding to the interface complicates things for
> future implementors. (Though String.intern() could be implemented in the
> reference implementation to just use the Hashtable like it is doing now.)
The trouble is: I load String and call clinit. In clinit is called init of
Hashtable and before it I must call clinit of Hashtable. And in clinit of
Hashtable is 'ldc #226 <String "loadFactor">' - I must create String (it
is not problem, only call constructor... yes, it load System and invoke
clinit and load Props and some IO and... but it is another story) and call
String.intern(). And it is problem, because clinit of String is not
completed, internTable (Hashtable) is now null, but intern wants to use
it!
(In my Logr Machine it is little more complicated, because I do not create
String in ldc but when I am loading class...)
One solution is do not call intern() while machine initialization - it is
posible, but I don't like such solution.
Vojta