Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 12410 invoked from network); 13 Sep 2005 16:07:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Sep 2005 16:07:56 -0000 Received: (qmail 98915 invoked by uid 500); 13 Sep 2005 16:07:51 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 98865 invoked by uid 500); 13 Sep 2005 16:07:50 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 98852 invoked by uid 99); 13 Sep 2005 16:07:50 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Sep 2005 09:07:50 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: 217.158.94.220 is neither permitted nor denied by domain of t.p.ellison@gmail.com) Received: from [217.158.94.220] (HELO cirrus.purplecloud.com) (217.158.94.220) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Sep 2005 09:08:01 -0700 Received: (qmail 26684 invoked from network); 13 Sep 2005 17:07:47 +0100 Received: from blueice2n1.uk.ibm.com (HELO ?9.20.183.166?) (195.212.29.75) by smtp.purplecloud.net with (DHE-RSA-AES256-SHA encrypted) SMTP; 13 Sep 2005 17:07:47 +0100 Message-ID: <4326F952.7010704@gmail.com> Date: Tue, 13 Sep 2005 17:07:46 +0100 From: Tim Ellison User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: harmony-dev@incubator.apache.org Subject: Re: [Arch] Class unloading and VM objects reclaim References: <9623c9a5050907194513922548@mail.gmail.com> <431FA752.8030407@dellroad.org> <9623c9a505090720232a8f24dc@mail.gmail.com> <2877.62.49.39.37.1126191068.squirrel@www.edworthy.org> <1126342699.24195.23.camel@localhost> <432324AE.2010401@dellroad.org> In-Reply-To: <432324AE.2010401@dellroad.org> X-Enigmail-Version: 0.92.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Archie Cobbs wrote: > Santiago Gala wrote: > >> IIRC, the (JVM spec v2) requirement for .equals String literals to be >> (==)identical only holds for Strings in the same .class file, but I >> could be wrong. > > > I believe the requirement is stronger than that. Any two > String literals (i.e., String constants from class files) > that are the same string must be the same object (==). > It doesn't matter if they come from different classes. I agree. All identical string literals must refer to the same instance. http://java.sun.com/docs/books/vmspec/2nd-edition/html/ConstantPool.doc.html#73272 >> In any case, interning all VM Strings in some sort of global weak set >> would do the trick, as shared literals would remain referenced on >> classloader collection, while unreferenced ones would be eligible for >> collection. This is typically how symbols in lisp or smalltalk are >> managed (most implementations don't even bother to use a weak structure, >> so symbols are never collected). Basically this is what String.intern() >> does, and nothing impedes us to actually use it for all Strings in the >> VM. > > > This is how Classpath works. Strings are intern'd using a weak > hash map and String.intern() is implemented in pure Java. > The JVM does nothing special for strings, with the exception > that when it creates them from class files it also interns them. I'd speculate that the VM interns many more strings loading classes than typical Java code calls to the API, so provided the call into Java is low-cost this works fine. > -Archie > > __________________________________________________________________________ > Archie Cobbs * CTO, Awarix * http://www.awarix.com > -- Tim Ellison (t.p.ellison@gmail.com) IBM Java technology centre, UK.