From: Andrew Haley <aph@redhat.com>
To: java-patches@gcc.gnu.org
Subject: Re: [PATCH] [JAVA] Double.parseDouble(null) throw NullPointerException
Date: Mon, 15 Aug 2011 14:07:00 -0000 [thread overview]
Message-ID: <4E48EB5C.9060500@redhat.com> (raw)
In-Reply-To: <CABc96T_DNYxNsqKqdsVw7-x8uVc05_fB0BcHfJU5rv-VtFUv7A@mail.gmail.com>
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 <java/lang/VMDouble.h>
> #include <java/lang/Character.h>
> #include <java/lang/NumberFormatException.h>
> +#include <java/lang/NullPointerException.h>
> #include <jvm.h>
>
> #include <stdio.h>
> @@ -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.
prev parent reply other threads:[~2011-08-15 9:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CABc96T_0THd_tKzdHSjD-xcPd7=dqoFkr0aRwrdvx-h4s2Hnxg@mail.gmail.com>
2011-08-07 11:00 ` Jie Liu
2011-08-08 14:16 ` Tom Tromey
2011-08-09 17:29 ` Jie Liu
2011-08-10 13:34 ` Tom Tromey
2011-08-10 15:59 ` Jie Liu
2011-08-10 16:41 ` Tom Tromey
2011-08-12 7:39 ` Jie Liu
2011-08-12 16:22 ` Bryce McKinlay
2011-08-12 17:12 ` Jie Liu
2011-08-14 13:04 ` Tom Tromey
2011-08-15 14:07 ` Andrew Haley [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E48EB5C.9060500@redhat.com \
--to=aph@redhat.com \
--cc=java-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).