This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [JAVA] Double.parseDouble(null) throw NullPointerException


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:

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?

Thanks,
Jie


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]