The java.lang.Integer.parseInt(String) method in the reference
implementation, now accepts "+", however, if just "+" is passed, a
NumberFormatException should be thrown.  

The reference implementation does not currently behave in this manner,
however, a new bug has been created stating that this behaviour is
expected:  http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6576055.


Here is the Changelog:

2007-07-03  Tania Bento  <[EMAIL PROTECTED]>

        * java/lang/Integer.java:
        (parseInt(String,int,boolean)): Throw NumberFormatException if
        String is just "+".



Index: java/lang/Integer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Integer.java,v
retrieving revision 1.35
diff -u -r1.35 Integer.java
--- java/lang/Integer.java	10 Dec 2006 20:25:44 -0000	1.35
+++ java/lang/Integer.java	3 Jul 2007 14:56:25 -0000
@@ -705,10 +705,13 @@
     if (len == 0)
       throw new NumberFormatException("string length is null");
     int ch = str.charAt(index);
-    if (ch == '-')
+    if (ch == '-' || ch == '+')
       {
         if (len == 1)
-          throw new NumberFormatException("pure '-'");
+          if (ch == '-')
+            throw new NumberFormatException("pure '-'");
+          else if (ch == '+')
+            throw new NumberFormatException("pure '+'");
         isNeg = true;
         ch = str.charAt(++index);
       }

Reply via email to