Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 88634 invoked from network); 2 Feb 2009 06:32:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Feb 2009 06:32:02 -0000 Received: (qmail 28066 invoked by uid 500); 2 Feb 2009 06:32:01 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 28024 invoked by uid 500); 2 Feb 2009 06:32:01 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 28013 invoked by uid 99); 2 Feb 2009 06:32:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Feb 2009 22:32:01 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [193.109.238.66] (HELO dnsinet.rzf-nrw.de) (193.109.238.66) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Feb 2009 06:31:52 +0000 Received: from z011100.bk.fin.local (z011100.bk.fin.local [172.18.101.140]) by dnsinet.rzf-nrw.de (8.14.0/8.14.0) with ESMTP id n126VTpq019214 for ; Mon, 2 Feb 2009 07:31:30 +0100 Received: from z011102.bk.fin.local ([130.11.7.102]) by z011100.bk.fin.local with Microsoft SMTPSVC(6.0.3790.1830); Mon, 2 Feb 2009 07:31:29 +0100 Received: from z011021.bk.fin.local ([130.11.7.21]) by z011102.bk.fin.local with Microsoft SMTPSVC(6.0.3790.1830); Mon, 2 Feb 2009 07:31:29 +0100 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: AW: svn commit: r739577 - /ant/core/trunk/src/main/org/apache/tools/ant/property/NullReturn.java Date: Mon, 2 Feb 2009 07:31:29 +0100 Message-ID: <9EE86F1965E19E499C80DE52AC807B5502A47A15@z011021.bk.fin.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: svn commit: r739577 - /ant/core/trunk/src/main/org/apache/tools/ant/property/NullReturn.java Thread-Index: AcmD6P2I40o24YadTWCYARBa+wclZABFRquA References: <72813.43547.qm@web55101.mail.re4.yahoo.com> <4984BF34.7030109@kruithof.xs4all.nl> From: To: X-OriginalArrivalTime: 02 Feb 2009 06:31:29.0767 (UTC) FILETIME=[E1DD3F70:01C984FF] X-Virus-Checked: Checked by ClamAV on apache.org Very curious ... Source of String.valueOf(Object) from JDK 1.4.2_15 /** * Returns the string representation of the Object = argument. * * @param obj an Object. * @return if the argument is null, then a string = equal to * "null"; otherwise, the value of * obj.toString() is returned. * @see java.lang.Object#toString() */ public static String valueOf(Object obj) { return (obj =3D=3D null) ? "null" : obj.toString(); }=20 The same for JDK 1.6.0_10 public static String valueOf(Object obj) { return (obj =3D=3D null) ? "null" : obj.toString(); } But indeed: Java 1.3.0-C : NPE Java 1.4.2_15-b02: NPE Java 1.5.0_12-b04: NPE Java 1.6.0_02-b05: NPE If I add a cast then it works System.out.println(String.valueOf( (Object)null )); So the compiler must bind that to another method than = String.valueOf(Object) ... But of course, simply returning "null" is much easier ;) Jan > -----Urspr=FCngliche Nachricht----- > Von: Martijn Kruithof [mailto:jm@kruithof.xs4all.nl]=20 > Gesendet: Samstag, 31. Januar 2009 22:14 > An: Ant Developers List > Betreff: Re: svn commit: r739577 -=20 > /ant/core/trunk/src/main/org/apache/tools/ant/property/NullReturn.java >=20 > Doubted it, checked it and it returned NullPointerException. >=20 > D:\>type Test.java > public class Test > { > public static void main(String[] args) > { > System.out.println(String.valueOf(null)); > } > } >=20 > D:\>java Test > Exception in thread "main" java.lang.NullPointerException > at java.lang.String.(Unknown Source) > at java.lang.String.valueOf(Unknown Source) > at Test.main(Test.java:6) >=20 > br Martijn >=20 > Matt Benson schreef: > > I always thought String.valueOf(null) returned "null". > > Was I on crack? > > > > -Matt > > > > P.S. Good to see you committing, Martijn... > > > > --- jkf@apache.org wrote: > > > > =20 > >> Author: jkf > >> Date: Sat Jan 31 17:10:50 2009 > >> New Revision: 739577 > >> > >> URL: > >> http://svn.apache.org/viewvc?rev=3D739577&view=3Drev > >> Log: > >> Original toString would always throw a NPE. > >> > >> Modified: > >> =20 > >> > >> =20 > >=20 > ant/core/trunk/src/main/org/apache/tools/ant/property/NullReturn.java > > =20 > >> Modified: > >> > >> =20 > >=20 > ant/core/trunk/src/main/org/apache/tools/ant/property/NullReturn.java > > =20 > >> URL: > >> > >> =20 > >=20 > http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apach > e/tools/ant/property/NullReturn.java?rev=3D739577&r1=3D739576&r2=3D7 39577&view=3Ddiff > > =20 > >=20 > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > =20 > >> --- > >> > >> =20 > >=20 > ant/core/trunk/src/main/org/apache/tools/ant/property/NullReturn.java > > =20 > >> (original) > >> +++ > >> > >> =20 > >=20 > ant/core/trunk/src/main/org/apache/tools/ant/property/NullReturn.java > > =20 > >> Sat Jan 31 17:10:50 2009 > >> @@ -33,6 +33,6 @@ > >> * {@inheritDoc} > >> */ > >> public String toString() { > >> - return String.valueOf(null); > >> + return "null"; > >> } > >> } > >> > >> > >> > >> =20 > > > > > > > > =20 > > > >=20 > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org > > For additional commands, e-mail: dev-help@ant.apache.org > > > > =20 >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org > For additional commands, e-mail: dev-help@ant.apache.org >=20 >=20 --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org