harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r425713 - in /incubator/harmony/enhanced/classlib/trunk/modules/math/src: main/java/java/math/BigDecimal.java test/java/org/apache/harmony/tests/java/math/BigDecimalConstructorsTest.java
Date Wed, 26 Jul 2006 11:49:13 GMT
Author: smishura
Date: Wed Jul 26 04:49:12 2006
New Revision: 425713

URL: http://svn.apache.org/viewvc?rev=425713&view=rev
Log:
Apply updated patch for HARMONY-783 ([classlib][math] unexpected ArrayIndexOutOfBoundsException
for java.math.BigDecimal(new char[] {}))

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigDecimal.java
    incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalConstructorsTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigDecimal.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigDecimal.java?rev=425713&r1=425712&r2=425713&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigDecimal.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigDecimal.java
Wed Jul 26 04:49:12 2006
@@ -262,7 +262,7 @@
      */
     public BigDecimal(char[] in, int offset, int len) {
         int endIndex = offset + len - 1;
-        if (offset < 0 || endIndex >= in.length) {
+        if (in.length == 0 || offset < 0 || endIndex >= in.length) {
             throw new NumberFormatException("the subarray exceeds the bounds" +
                                             " of the array");
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalConstructorsTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalConstructorsTest.java?rev=425713&r1=425712&r2=425713&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalConstructorsTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalConstructorsTest.java
Wed Jul 26 04:49:12 2006
@@ -134,6 +134,13 @@
         int resScale = 427;
         assertEquals("incorrect value", res, result.toString());
         assertEquals("incorrect scale", resScale, result.scale());
+        
+        try {
+            // Regression for HARMONY-783
+            new BigDecimal(new char[] {});
+            fail("NumberFormatException has not been thrown");
+        } catch (NumberFormatException e) {
+        }
      }
     
     /**
@@ -148,6 +155,13 @@
         int resScale = 46;
         assertEquals("incorrect value", res, result.toString());
         assertEquals("incorrect scale", resScale, result.scale());
+        
+        try {
+            // Regression for HARMONY-783
+            new BigDecimal(new char[] {}, 0, 0);
+            fail("NumberFormatException has not been thrown");
+        } catch (NumberFormatException e) {
+        }
      }
     
     /**
@@ -165,6 +179,13 @@
         int resScale = 43;
         assertEquals("incorrect value", res, result.toString());
         assertEquals("incorrect scale", resScale, result.scale());
+        
+        try {
+            // Regression for HARMONY-783
+            new BigDecimal(new char[] {}, 0, 0, MathContext.DECIMAL32);
+            fail("NumberFormatException has not been thrown");
+        } catch (NumberFormatException e) {
+        }
      }
     
     /**
@@ -200,6 +221,18 @@
         } catch (NumberFormatException e) {
         }
      }
+
+    /**
+     * new BigDecimal(char[] value, MathContext mc);
+     */
+    public void testConstrCharMathContext() {
+        try {
+            // Regression for HARMONY-783
+            new BigDecimal(new char[] {}, MathContext.DECIMAL32);
+            fail("NumberFormatException has not been thrown");
+        } catch (NumberFormatException e) {
+        }
+    }
     
     /**
      * new BigDecimal(double value) when value is NaN



Mime
View raw message