Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 19130 invoked from network); 16 Nov 2010 14:42:38 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Nov 2010 14:42:38 -0000 Received: (qmail 46392 invoked by uid 500); 16 Nov 2010 14:43:09 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 46184 invoked by uid 500); 16 Nov 2010 14:43:09 -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 46175 invoked by uid 99); 16 Nov 2010 14:43:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Nov 2010 14:43:08 +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 (nike.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 14:43:02 +0000 Received: by vws1 with SMTP id 1so221386vws.36 for ; Tue, 16 Nov 2010 06:42:41 -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 :content-transfer-encoding; bh=4BuITW9JinJ+QSFQh7sqFVH0YO2xpdiQYjRrPnMe/z4=; b=LaNB6Ht6nuCBPLlgb7yPrdqIYoQ+Wm+7so1iunyHK81h+Dq6O7F0NdmfDeed2YzOVe P5K3lnEkM1adAiPMGBf1oe6/dmrGCT9t338uTqn0xBGpqbfFUCtlVsnxlLWEsW5IpDkP G9AShScVAXvJnL68Wt6dpyI6w1v3QfZvwa3Pg= 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:content-transfer-encoding; b=TsDu8BZEnmCfuYoppY4JwuDCqBIdw/WRqX5DOfq7wAB3pbayRcU22RzRG/7P6jMsj/ XTGI4TKzYWRCNYehQ6IUxaNqrxS9WvZfgGPJKj6ExKk8D408K0CjS5ijTQ4IqGw9vMSl 2W8QDZLFmru3hQUBGEx0BUOyuBphZzcTXbo9A= MIME-Version: 1.0 Received: by 10.229.225.199 with SMTP id it7mr6429749qcb.33.1289918561199; Tue, 16 Nov 2010 06:42:41 -0800 (PST) Received: by 10.229.72.94 with HTTP; Tue, 16 Nov 2010 06:42:41 -0800 (PST) In-Reply-To: <1F34158EF96C4B24AE53B36616FB26A5@emea.itt.net> References: <4ce28ac1.9a9ce60a.061f.3b4e@mx.google.com> <1F34158EF96C4B24AE53B36616FB26A5@emea.itt.net> Date: Tue, 16 Nov 2010 14:42:41 +0000 Message-ID: Subject: Re: Question about Character.valueOf() From: sebb To: dev@harmony.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org 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 =3D=3D 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 obje= ct > 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 { >> >> =A0 public void test_valueOfC() { >> =A0 =A0 =A0 // test the cache range >> =A0 =A0 =A0 for (char c =3D '\u0000'; c < 512; c++) { >> =A0 =A0 =A0 =A0 =A0 Character e =3D new Character(c); >> =A0 =A0 =A0 =A0 =A0 Character a =3D Character.valueOf(c); >> =A0 =A0 =A0 =A0 =A0 assertEquals(e, a); >> >> =A0 =A0 =A0 =A0 =A0 // WARN: this assertion may not be valid on other JR= Es >> =A0 =A0 =A0 =A0 =A0 assertSame(Character.valueOf(c), Character.valueOf(c= )); >> =A0 =A0 =A0 } >> =A0 =A0 =A0 // test the rest of the chars >> =A0 =A0 =A0 for (int c =3D '\u0512'; c <=3D Character.MAX_VALUE; c++) { >> =A0 =A0 =A0 =A0 =A0 assertEquals(new Character((char) c), Character.valu= eOf((char) >> c)); >> =A0 =A0 =A0 } >> =A0 } >> } >> 2010-11-16 >> >> >> >> lcj.dev > >