Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 61611 invoked from network); 8 Oct 2009 15:47:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Oct 2009 15:47:03 -0000 Received: (qmail 7170 invoked by uid 500); 8 Oct 2009 15:47:03 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 7141 invoked by uid 500); 8 Oct 2009 15:47:03 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 7132 invoked by uid 99); 8 Oct 2009 15:47:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Oct 2009 15:47:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Oct 2009 15:46:52 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 75BEA234C1EF for ; Thu, 8 Oct 2009 08:46:31 -0700 (PDT) Message-ID: <1832438987.1255016791481.JavaMail.jira@brutus> Date: Thu, 8 Oct 2009 08:46:31 -0700 (PDT) From: "Tim Ellison (JIRA)" To: commits@harmony.apache.org Subject: [jira] Closed: (HARMONY-6272) [classlib][math] BigDecimal.divide throws ArrayIndexOufOfBoundsException when called with too large scale In-Reply-To: <2100561129.1247560994810.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on 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.