Code review request for #6469160, #7088271

Brandon Passanisi brandon.passanisi at oracle.com
Wed Jan 4 18:26:45 UTC 2012


Resending...

Hello core-libs.  I was wondering of somebody could be please review the 
following fix for #6469160 and #7088271.  The changes in the webrev fix 
both bugs.  Information is below:

    Webrev URL: http://cr.openjdk.java.net/~bpassani/6469160_7088271/1/
    <http://cr.openjdk.java.net/%7Ebpassani/6469160_7088271/1/>
    Bug #6469160: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6469160
    Bug #7088271: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7088271

Both bugs uncover the current behavior where using a 0 or 1 precision 
value with a float zero causes an ArrayIndexOutOfBoundsException.  The 
current code in FormattedFloatingDecimal.java interprets the float zero 
as "0.0" in the case where precision is 0 or 1 and returns the length of 
it's characters as 3.  Later in Formatter.addZeros(), the character 
array "0.0" is passed in, but a new array of only 1 character is 
allocated.  When an System.arraycopy() is performed, the 
ArrayIndexOutOfBoundsException occurs.  In fact, when run with "-esa" an 
AssertionError occurs at "assert (outPrec <= prec);" on line 3393 of 
Formatter.java.  The fix is for FormatedFloatingDecimal.java to 
interpret the float zero as a single "0" because of the precision being 
set to 0 or 1.

Since java has been throwing exceptions in these cases, I consulted with 
the output of C's printf to make sure that the outputted strings are the 
same.  I updated the Formatter's Basic-X template of tests with a little 
over 20 test format strings that were causing exceptions without the 
change and the output of each is compared with the output from C's 
printf with the same format string.  And, I ran all of the Basic-X tests 
to make sure there weren't any regressions in behavior.

Thanks.
-- 
Oracle <http://www.oracle.com>
Brandon Passanisi | Principle Member of Technical Staff


Green Oracle <http://www.oracle.com/commitment> Oracle is committed to 
developing practices and products that help protect the environment



More information about the core-libs-dev mailing list