[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: String.equals optimisation
From: |
Robert Lougher |
Subject: |
Re: String.equals optimisation |
Date: |
Tue, 12 Jul 2005 15:40:33 +0100 |
Hi,
On 7/12/05, Archie Cobbs <address@hidden> wrote:
> Simon Kitching wrote:
> >>>* Class.getName returns strings that have been interned. I don't
> >>> think this is explicitly required by the java specs but is
> >>> certainly true for Sun's JVM and seems likely to be done by
> >>> any sensible JVM.
> >>
> >>You definitely make some good arguments, but this one is not
> >>neccesarily true. In fact, I'd argue a JVM that interns every
> >>class' name (even if only on demand) is potentially wasting
> >>a bunch of heap space.
> >
> > I'm assuming that the Class object would contain a reference to the
> > interned string, so there is only one copy of the string, ie somewhere
>
> Not a valid assumtion.. in JC no String is associated with Class
> objects. VMClass.getName() is native and the returned String is
> created on demand, based on the UTF-8 name stored internally in memory.
>
It might also be worthwhile to mention that the internal class name
uses slash as a separator, instead of the dot returned by getName(),
e.g. java/lang/String, rather than java.lang.String.
Rob.