On Dec 16, 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.)
As I currently think of writing my own JVM I have thought a bit about
bootstrap isssues. Before I can call a java method like
String.intern(), I have to link and initialize that class and probably
many others like java.util.Hashtable, some io classes (look in
String.<clinit>), etc. When linking a class I have to resolve the
constant pool. And while resolving the constant pool I have to create
interned Strings. This is the chicken and egg problem.
I would rather make String.intern() native for this reason.
Jochen