From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25913 invoked by alias); 15 Aug 2011 09:48:28 -0000 Received: (qmail 25904 invoked by uid 22791); 15 Aug 2011 09:48:28 -0000 X-SWARE-Spam-Status: No, hits=-7.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_GC X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Aug 2011 09:48:14 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7F9mEe4014548 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 15 Aug 2011 05:48:14 -0400 Received: from zebedee.pink (ovpn-116-31.ams2.redhat.com [10.36.116.31]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7F9mD5R028590; Mon, 15 Aug 2011 05:48:13 -0400 Message-ID: <4E48EB5C.9060500@redhat.com> Date: Mon, 15 Aug 2011 14:07:00 -0000 From: Andrew Haley User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Thunderbird/3.1.11 MIME-Version: 1.0 To: java-patches@gcc.gnu.org Subject: Re: [PATCH] [JAVA] Double.parseDouble(null) throw NullPointerException References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact java-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-patches-owner@gcc.gnu.org X-SW-Source: 2011-q3/txt/msg00074.txt.bz2 On 08/07/2011 12:00 PM, Jie Liu wrote: > When I use gcj on an RTOS(RTEMS), Double.parseDouble(null) throw > NumberFormatException, but it should throw NullPointerException. So I > add the patch below: > > Index: natVMDouble.cc > =================================================================== > --- natVMDouble.cc (revision 172224) > +++ natVMDouble.cc (working copy) > @@ -19,6 +19,7 @@ > #include > #include > #include > +#include > #include > > #include > @@ -162,6 +163,9 @@ > jdouble > java::lang::VMDouble::parseDouble(jstring str) > { > + if(str == NULL) > + throw new NullPointerException(); > + > int length = str->length(); > > while (length > 0 > > The testsuite/Throw_2.java has been PASS after this patch. what do you > think about this patch? This patch is not OK, and must not go in. Look at the comment at the top of Throw_2: // Check that NullPointerExceptions thrown from library code are // caught. This detects a number of failures that can be caused by // libgcj being built incorrectly. In particular, we ensure that a // SEGV in native (i.e. C++) code in libgcj is handled correctly. // Regrettably, we cannot guarantee that Double.parseDouble() will // always be native code, or that it will never be inlined. It could // be argued that we should add a method to libgcj that will be // guaranteed forever to be native, but I'm reluctant to add to the // library for the sole purpose of performing this test. Andrew.