Index: modules/math/src/main/java/java/math/Multiplication.java =================================================================== --- modules/math/src/main/java/java/math/Multiplication.java (revision 793515) +++ modules/math/src/main/java/java/math/Multiplication.java (working copy) @@ -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 Index: modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerDivideTest.java =================================================================== --- modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerDivideTest.java (revision 793515) +++ modules/math/src/test/java/org/apache/harmony/tests/java/math/BigIntegerDivideTest.java (working copy) @@ -22,6 +22,8 @@ package org.apache.harmony.tests.java.math; import junit.framework.TestCase; + +import java.math.BigDecimal; import java.math.BigInteger; /** @@ -668,4 +670,19 @@ } assertEquals("incorrect sign", 1, result.signum()); } + + /** + * divide with a scale that's too large + */ + public void testCase25() { + BigDecimal arg1 = new BigDecimal("1"); + BigDecimal arg2 = new BigDecimal("2"); + try { + BigDecimal result = arg1.divide(arg2, 1000000000, + java.math.RoundingMode.CEILING); + fail("Expected ArithmeticException when dividing with a scale that's too large"); + } catch (ArithmeticException e) { + // expected behaviour + } + } }