harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Ellison (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HARMONY-6272) [classlib][math] BigDecimal.divide throws ArrayIndexOufOfBoundsException when called with too large scale
Date Thu, 08 Oct 2009 16:38:31 GMT

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

Tim Ellison updated HARMONY-6272:
---------------------------------

    Comment: was deleted

(was: Closing this JIRA again -- seems to have been rolled back.

See:   http://markmail.org/thread/q7kcdtx6sv5q676k)

> [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
>             Fix For: 5.0M11
>
>         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