harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r798486 - in /harmony/enhanced/classlib/trunk/modules/math/src: main/java/java/math/Multiplication.java test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java
Date Tue, 28 Jul 2009 11:10:56 GMT
Author: hindessm
Date: Tue Jul 28 11:10:55 2009
New Revision: 798486

URL: http://svn.apache.org/viewvc?rev=798486&view=rev
Log:
Applied patch from "[#HARMONY-6271] [classlib][math] BigDecimal.divide
should throw an ArithmeticException instead of OutOfMemory for too
large scales".

Modified:
    harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Multiplication.java
    harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java

Modified: harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Multiplication.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Multiplication.java?rev=798486&r1=798485&r2=798486&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Multiplication.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/Multiplication.java
Tue Jul 28 11:10:55 2009
@@ -440,7 +440,7 @@
         
         if (byteArraySize > Runtime.getRuntime().freeMemory()) {
             // math.01=power of ten too big
-            throw new OutOfMemoryError(Messages.getString("math.01")); //$NON-NLS-1$
+            throw new ArithmeticException(Messages.getString("math.01")); //$NON-NLS-1$
         }
         if (exp <= Integer.MAX_VALUE) {
             // To calculate:    5^exp * 2^exp

Modified: harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java?rev=798486&r1=798485&r2=798486&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/java/math/BigDecimalArithmeticTest.java
Tue Jul 28 11:10:55 2009
@@ -1287,6 +1287,24 @@
         assertEquals("incorrect scale", resScale, result.scale());
     }
 
+
+    /**
+     * BigDecimal.divide with a scale that's too large
+     * 
+     * Regression test for HARMONY-6271
+     */
+    public void testDivideLargeScale() {
+    	BigDecimal arg1 = new BigDecimal("320.0E+2147483647");
+		BigDecimal arg2 = new BigDecimal("6E-2147483647");
+    	try {
+    		BigDecimal result = arg1.divide(arg2, Integer.MAX_VALUE, 
+    				java.math.RoundingMode.CEILING);
+    		fail("Expected ArithmeticException when dividing with a scale that's too large");
+    	} catch (ArithmeticException e) {
+    		// expected behaviour
+    	}
+    }
+
     /**
      * divideToIntegralValue(BigDecimal)
      */



Mime
View raw message