harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Fursov" <mike.fur...@gmail.com>
Subject Re: [drlvm] string interning in java
Date Fri, 28 Jul 2006 18:11:13 GMT
I wonder why such an elegant solution haven't been made before?

The benefit of String.intern I know:
1) Fast comparison (May be we can speedup some internal algorithms like
reflection this way?)
2) Low memory consumption if there are a lot of duplicates

The overhead:
1) AFAIK every access to the weakmap must be synchronized.

On 7/28/06, Salikh Zakirov <Salikh.Zakirov@intel.com> wrote:
> Salikh Zakirov wrote:
> >> Subject: [PATCH] Pure java string intern()
> I have just been privately asked by a fellow colleague
> what the interning is used for.
> So I figured it would be nice to describe the answer on the list
> too, especially because I am interested in learning something new
> on the subject :)
> The most important reason I know is that interning
> is required by the specification.
> A particular use case I know is message localization: having string
> literals interned by default allows to optimize the lookup
> in the message bundles, as we can intern the keys on loading
> the bundle, and use object reference comparison later at lookup time.
> While I was working on the patch, there was a moment when I screwed
> the condition in intern() function, and it worked incorrectly,
> and returned incorrect strings sometimes. When I tried to run
> Eclipse with the bug, it complained about missing localization
> string and terminated by exception.
> Any other insights?
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org

Mikhail Fursov

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message