JDK-4117447 : RFE: No BigDecimalFormat & Format has and UNACCEPTABLE final method
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 1.1.4,1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5,windows_95
  • CPU: x86,sparc
  • Submitted: 1998-03-05
  • Updated: 1998-10-29
  • Resolved: 1998-10-29
Related Reports
Duplicate :  
Duplicate :  
Description

Name: rm29839			Date: 03/05/98


/*    Bug report dmg.bug1.1.5_0003 ("public final" makes numeric part
      ==========                     of java.text ALMOST USELESS)
      Code snippet follows
*/
import java.text.NumberFormat;

public abstract class DmgBug0002 extends NumberFormat {  // actual class name is
                                                // BigDecimalFormat
      public StringBuffer format(Object number,
                              StringBuffer toAppendTo,
                              FieldPosition pos) {
      if (! (number instanceof BigDecimal))
         return super.format(number, toAppendTo, pos);
      // actual processing of a BigDecimal
   }
}

/*
   COMPILE PROBLEM
     Final methods can't be overriden.

     inspecting the source:
    (extract from java.text.DecimalFormat);
    public final StringBuffer format(Object number,
           =====
           ?????
                                     StringBuffer toAppendTo,
                                     FieldPosition pos)
    {
        if (number instanceof Double || number instanceof Float) {
            return format(((Number)number).doubleValue(), toAppendTo, pos);
        }
        else if (number instanceof Number) {
            return format(((Number)number).longValue(), toAppendTo, pos);
                   ==================================== ???????????
        }
        else {
            throw new IllegalArgumentException("Cannot format given Object as a Number");
        }
    }

    The problem exists in both JDK1.1.5 & JDK1.2 Beta 2.

    java.math.BigDecimal Implements java.lang.Number

    Double and Float are not acceptable in Commercial Applications,
    expecially Stock Exchange Trading where currency conversions are
    stated with with 4 SIGNIFICANT positions after the decimal point
    and where it is often necessary to cross calculate a conversion
    rate (eg.    ISK -> DM -> PLZ).

    I was of the optinion that java.math.BigDecimal was intented both
    for jdbc applications AND FOR COMMERCIAL applications in java? But
    neither a java.[math|text].BigDecimalFormat exists nor is it easily
    possible really to extend java.lang.Number.

    Is nobody really using java for the mundane tasks of traditional
    commercial data processing?

    PLEASE PLEASE remove the 'final' marked above in the next releases
    (JDK 1.1.6 & JDK 1.2 ??? - beta 3 is probably already finalized by
    now so I don't know what will be the release after 1.2 beta 3).


    Platforms & SW Versions
    =======================
       MS-Win95 (Cyrix 6x86 200MX)    (JDK1.2 beta 2) JDK 1.1.5 swing 1.0.1
       MS-WinNT (PentiumPro 200 MHz)  (JDK1.2 beta 2) JDK 1.1.5 swing 1.0.1
       AIX 4.1  (PowerPC 128MHz)      JDK 1.1.4 swing 1.0.1

  Hoping that this report helps you more than java.text has helped me in
  the commercial programming area.
  I remain
  yours faithfully

  David M. Gaskin
  (###@###.###).

*/
(Review ID: 26048)
======================================================================

Comments
EVALUATION The part of this bug that can be fixed with no API change has been fixed. The remaining bug (no support for BigDecimal & BigInteger) is a duplicate.
11-06-2004