Urgent [9] RFR (S) : JDK-8039915 NumberFormat.format() does not consider required no. of fraction digits properly

William Price wprice at pros.com
Fri Sep 19 17:08:43 UTC 2014


Hi Oliver,

I wrote a javaagent-based patch for this bug.  I haven't contributed it formally since my employer's legal department is still hung up on the Oracle Contributor Agreement (though we have released it on GitHub under GPLv2 w/CPE).  I'm not linking to it here under the assumption that your patch was developed independently and I don't want to confuse the issue with legalities.  I copied your patch into my shim locally and ran my test cases and still get a couple failures (see output below).  Your patch and my version differ in the way and order in which we interpret allDecimalDigits and alreadyRounded.

PATCH SELF TEST:
  java.text.DigitList.shouldRoundUp(int,boolean,boolean)
  HALF_UP case

StackOverflow.com question 24426438 test case 1:
         6.2088 HALF_UP --> 6.209               OK
         6.2089 HALF_UP --> 6.209               OK

StackOverflow.com question 24426438 test case 2:
            0.0 HALF_UP --> 0                   OK
           ...
           0.14 HALF_UP --> 0.1                 OK
           0.15 HALF_UP --> 0.1                 expected: 0.2
           0.16 HALF_UP --> 0.2                 OK
           ...
           0.34 HALF_UP --> 0.3                 OK
           0.35 HALF_UP --> 0.3                 expected: 0.4
           0.36 HALF_UP --> 0.4                 OK
           ...
           0.84 HALF_UP --> 0.8                 OK
           0.85 HALF_UP --> 0.8                 expected: 0.9
           0.86 HALF_UP --> 0.9                 OK
           ...
           0.94 HALF_UP --> 0.9                 OK
           0.95 HALF_UP --> 0.9                 expected: 1
           0.96 HALF_UP --> 1                   OK
           ...
           0.99 HALF_UP --> 1                   OK

JDK-8041961 test case:
        99.9989 HALF_UP --> 100                 OK
         99.999 HALF_UP --> 100                 OK

JDK-8039915 test case:
     0.95000055 HALF_UP --> 0.950001            OK
      0.9500006 HALF_UP --> 0.950001            OK

Above tests used Java 1.8.0_20 (Oracle Corporation)
installed at C:\JAVA\latest8\jre

Agent installed: yes
Patch applied  : yes

Overall result : BAD PATCH (!) on Oracle Corporation Java 1.8.0_20

-- 
William Price | Software Architect | PROS, Inc.
Phone: +1 713-335-5244







More information about the core-libs-dev mailing list