diff mbox

[JAVA] Double.parseDouble(null) throw NullPointerException

Message ID CABc96T_DNYxNsqKqdsVw7-x8uVc05_fB0BcHfJU5rv-VtFUv7A@mail.gmail.com
State New
Headers show

Commit Message

Jie Liu Aug. 7, 2011, 11 a.m. UTC
Hi,

When I use gcj on an RTOS(RTEMS), Double.parseDouble(null) throw
NumberFormatException, but it should throw NullPointerException. So I
add the patch below:


The testsuite/Throw_2.java has been PASS after this patch. what do you
think about this patch?

Thanks,
Jie

Comments

Tom Tromey Aug. 8, 2011, 2:15 p.m. UTC | #1
>>>>> "Jie" == Jie Liu <lj8175@gmail.com> writes:

Jie> +  if(str == NULL)
Jie> +      throw new NullPointerException();
Jie> +
Jie>    int length = str->length();

Why doesn't 'str->length()' throw the NPE?

Tom
diff mbox

Patch

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