Patch: finalize interned strings

Bryce McKinlay bryce@albatross.co.nz
Wed Apr 12 15:39:00 GMT 2000


Jeff Sturm wrote:

> I was considering race conditions.  Imagine this: an interned string
> becomes collectable so it is scheduled for finalization.  But before
> finalization can occur, another thread calls intern() and grabs a
> reference to the finalizing string object.  When finalization does occur
> it becomes uninterned but is not collected because it is no longer a
> dead object.  And the thread that called intern() thinks it has an
> interned string, but doesn't.

I don't think this can happen with our particular gc implementation,
because it stops all threads before marking begins. But perhaps this could
be a problem with concurrent collectors.

> FWIW it took Sun a long time to get this right... versions of the JDK
> prior to 1.2 never released interned strings.

Yeah, I don't think Kaffe does either.

regards

  [ bryce ]




More information about the Java-patches mailing list