You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Catherine Hope (JIRA)" <ji...@apache.org> on 2009/07/14 10:43:14 UTC
[jira] Created: (HARMONY-6272) [classlib][math] BigDecimal.divide
throws ArrayIndexOufOfBoundsException when called with too large scale
[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
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.
[jira] Updated: (HARMONY-6272) [classlib][math] BigDecimal.divide
throws ArrayIndexOufOfBoundsException when called with too large scale
Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Updated: (HARMONY-6272) [classlib][math] BigDecimal.divide
throws ArrayIndexOufOfBoundsException when called with too large scale
Posted by "Catherine Hope (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Reopened: (HARMONY-6272) [classlib][math] BigDecimal.divide
throws ArrayIndexOufOfBoundsException when called with too large scale
Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6272?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tim Ellison reopened HARMONY-6272:
----------------------------------
Assignee: (was: Tim Ellison)
> [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.
[jira] Commented: (HARMONY-6272) [classlib][math] BigDecimal.divide
throws ArrayIndexOufOfBoundsException when called with too large scale
Posted by "Catherine Hope (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6272?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12730808#action_12730808 ]
Catherine Hope commented on HARMONY-6272:
-----------------------------------------
I've found a few other places that has the int cast problem, so I'll apply them all at once
> [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.
[jira] Closed: (HARMONY-6272) [classlib][math] BigDecimal.divide
throws ArrayIndexOufOfBoundsException when called with too large scale
Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6272?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tim Ellison closed HARMONY-6272.
--------------------------------
Resolution: Fixed
Fix Version/s: 5.0M11
Assignee: Tim Ellison
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
> Assignee: Tim Ellison
> 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.