harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Catherine Hope (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-6272) [classlib][math] BigDecimal.divide throws ArrayIndexOufOfBoundsException when called with too large scale
Date Tue, 14 Jul 2009 11:43:15 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-6272?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Catherine Hope updated HARMONY-6272:
------------------------------------

    Attachment: patch.txt

 Please ignore previous patch - I added the testcase to the wrong junit class.  Now moved
in org.apache.harmony.tests.java.math.BigDecimalArithmeticTest

> [classlib][math] BigDecimal.divide throws ArrayIndexOufOfBoundsException when called
with too large scale
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-6272
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6272
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: all
>            Reporter: Catherine Hope
>         Attachments: patch.txt
>
>
> BigDecimal.divide(BigDecimal, int, RoundingMode) throws an ArrayIndexOutOfBoundsException
when called with a scale that's too large, instead of the expected ArithmeticException.
> testcase:
> BigDecimal bd = (new BigDecimal("4")).divide(new BigDecimal("1"), Integer.MAX_VALUE,
1);
> java.lang.ArrayIndexOutOfBoundsException: Array index out of range: -2147483644
> 	at java.math.Multiplication.multiplyByTenPow(Multiplication.java:409)
> 	at java.math.BigDecimal.movePoint(BigDecimal.java:2062)
> 	at java.math.BigDecimal.movePointLeft(BigDecimal.java:2043)
> The exception is thrown from Multiplication.multiplyByTenPow which is being called with
a negative index, though it has a precondition that it should be 0 or above.  This is occurring
since there's an unnecessary cast to int after a negation, which means if:
> long l = -(Integer.MAX_VALUE + 1);
> long negate = (int)-l;
> then negate is still set to -(Integer.MAX_VALUE + 1) instead of (Integer.MAX_VALUE +
1)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message