This is the mail archive of the java-patches@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch: String.unintern


Tom Tromey wrote:

> Bryce> InternHog.java from Kaffe is one test. With you're patch, it is
> Bryce> currently failing after 12179 iterations in rehash().
>
> Thanks.  Part of the problem is that String.rehash is not checking the
> result of _Jv_AllocBytes.  I'm changing it to use
> _Jv_AllocBytesChecked; this will cause it to signal out of memory
> instead of null pointer exception.
>
> The fact that it runs out of memory at all seems to indicate something
> fishy is going on.  I'll debug it.

Hmm. I figured it could fail because rehash() could be called when
strings had become unreachable and been collected, but their finalizers
hadn't been run. rehash() has no way to determine if a pointer it finds
in the old hashtable is valid or not, but it can't put the entry in the
new hashtable without calling hashCode() on it. It seems that the GC
needs to atomically update the hashtable entry for this to work (maybe
this is guaranteed in the current finalization implementation, but it
certainly wont work when we change to having a finalizer thread).

Another issue I recall is: if two (different) strings hash to the same
entry in the table, and the first entry subsequently gets deleted, will
another call to intern() for the second string still find it?

regards

  [ bryce ]



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]