Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 95066 invoked from network); 16 Nov 2010 13:50:54 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Nov 2010 13:50:54 -0000 Received: (qmail 74766 invoked by uid 500); 16 Nov 2010 13:51:25 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 74599 invoked by uid 500); 16 Nov 2010 13:51:25 -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 74590 invoked by uid 99); 16 Nov 2010 13:51:25 -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 13:51:25 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [195.67.226.200] (HELO smtp-out11.han.skanova.net) (195.67.226.200) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Nov 2010 13:51:17 +0000 Received: from W193MTEC (213.67.146.211) by smtp-out11.han.skanova.net (8.5.124.10) (authenticated as u35603170) id 4C7E127001E4E3B5 for dev@harmony.apache.org; Tue, 16 Nov 2010 14:50:54 +0100 Message-ID: <1F34158EF96C4B24AE53B36616FB26A5@emea.itt.net> From: "Mikael" To: References: <4ce28ac1.9a9ce60a.061f.3b4e@mx.google.com> Subject: Re: Question about Character.valueOf() Date: Tue, 16 Nov 2010 14:50:36 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="UTF-8"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994 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