Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 40768 invoked from network); 16 Nov 2010 15:23:31 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Nov 2010 15:23:31 -0000 Received: (qmail 12324 invoked by uid 500); 16 Nov 2010 15:24:02 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 12007 invoked by uid 500); 16 Nov 2010 15:24:01 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 11997 invoked by uid 99); 16 Nov 2010 15:24:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Nov 2010 15:24:00 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sebbaz@gmail.com designates 209.85.212.49 as permitted sender) Received: from [209.85.212.49] (HELO mail-vw0-f49.google.com) (209.85.212.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Nov 2010 15:23:55 +0000 Received: by vws1 with SMTP id 1so263643vws.36 for ; Tue, 16 Nov 2010 07:23:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=zV2abdiChguOIDxKl1fMrUE8dTuJRms/J1zWnizPmnQ=; b=L9jF3f+UsNXAM8b/H/vWo7aMMWRNt0OoTYbTBvZPueoiDZKhkScBbAJlL+SA+L02Pt Q9NlNzjkRQEkrBGRrE3EB3fO3yCSqxHezzieJGjhJYLUt6jz4p6NNp9bqKRroHCtKX9n 4Ho3x7zuRZ30lobAY+FBz3ejWo3h4PpKFcAgk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=FmUUQA8Z6W4gDkyXEbzShZa65tHdUtT7v8Sfm7PwWJXPpR7MwcKIY7TGRJcXP6fNlz OeSMemL+DijgBw8yEKG5UJMJ1zxJde+Z8JFXVheuEv3IEjsmk/2pSgK6Kq+IyTp6dKC1 6XysSwEuKrTprEYqoR/+bscV40S4hxPu/RZLg= MIME-Version: 1.0 Received: by 10.229.225.199 with SMTP id it7mr6461535qcb.33.1289921014184; Tue, 16 Nov 2010 07:23:34 -0800 (PST) Received: by 10.229.72.94 with HTTP; Tue, 16 Nov 2010 07:23:34 -0800 (PST) In-Reply-To: <4EEE3D20740242D0BCECEF1D0E3EDFB3@emea.itt.net> References: <4ce28ac1.9a9ce60a.061f.3b4e@mx.google.com> <1F34158EF96C4B24AE53B36616FB26A5@emea.itt.net> <4EEE3D20740242D0BCECEF1D0E3EDFB3@emea.itt.net> Date: Tue, 16 Nov 2010 15:23:34 +0000 Message-ID: Subject: Re: Question about Character.valueOf() From: sebb To: dev@harmony.apache.org Content-Type: text/plain; charset=ISO-8859-1 Yes, but the point is that there is at least a partial guarantee. On 16 November 2010 14:55, Mikael wrote: > But that's only for Character 0x00 to 0x7F, the loop with the assert test > counts from 0 to 512. > > ----- Original Message ----- From: "sebb" > To: > Sent: Tuesday, November 16, 2010 3:42 PM > Subject: Re: Question about Character.valueOf() > > > The end of section 5.1.7 > > http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.7 > > says: > > "If the value p being boxed is true, false, a byte, a char in the > range \u0000 to \u007f, or an int or short number between -128 and > 127, then let r1 and r2 be the results of any two boxing conversions > of p. It is always the case that r1 == r2." > > [See also subsequent discussion section] > > AFAIK, boxing uses valueOf to achieve this. > > On 16 November 2010 13:50, Mikael wrote: >> >> As far as I know there is no guarantee that valueOf returns the same >> object >> every time, it just gives class a chance to do it if it wants to. >> >> ----- Original Message ----- From: "lcj.dev" >> To: "dev" >> Sent: Tuesday, November 16, 2010 2:44 PM >> Subject: Question about Character.valueOf() >> >> >>> Hi, all >>> Why this may be failed for other JREs? assertSame(Character.valueOf(c), >>> Character.valueOf(c)). >>> Thanks. >>> >>> please refers to this test case for details: >>> package org.apache.harmony.luni.tests.java.lang; >>> >>> import junit.framework.TestCase; >>> >>> public class CharacterImplTest extends TestCase { >>> >>> public void test_valueOfC() { >>> // test the cache range >>> for (char c = '\u0000'; c < 512; c++) { >>> Character e = new Character(c); >>> Character a = Character.valueOf(c); >>> assertEquals(e, a); >>> >>> // WARN: this assertion may not be valid on other JREs >>> assertSame(Character.valueOf(c), Character.valueOf(c)); >>> } >>> // test the rest of the chars >>> for (int c = '\u0512'; c <= Character.MAX_VALUE; c++) { >>> assertEquals(new Character((char) c), Character.valueOf((char) >>> c)); >>> } >>> } >>> } >>> 2010-11-16 >>> >>> >>> >>> lcj.dev >> >> > >