Hi Ivan,

2010/12/6 Ivan Maidanski <iv...@mail.ru>:
>> > Sorry for the provided test below - it doesn't test the things that
>> are fixed by the attached patch. In fact, the test is for a bug that has been
>> already fixed since Classpath v0.93 (by not relying on 
>> setMaximumIntegerDigits
>> implementation). So, the correct test is:
>> >
>> > import java.text.*;
>> > import java.util.*;
>> > public class DecimalFormatTest {
>> >  public static void main(String[] args) throws ParseException {
>> >    NumberFormat numberFormat =
>> NumberFormat.getInstance(Locale.getDefault());
>> >    numberFormat.setGroupingUsed (false);
>> >    numberFormat.setParseIntegerOnly (true);
>> >    numberFormat.setMaximumFractionDigits (0);
>> >    int fmt_count = 2;
>> >    numberFormat.setMinimumIntegerDigits(fmt_count);
>> >    numberFormat.setMaximumIntegerDigits(fmt_count);
>> >    System.out.println(numberFormat.parse("1234567890")); //
>> should print "12"
>> >  }
>> > }
>> >
>> > It tests the following code change (by the attached patch) in
>> DecimalFormat.parse():
>> >
>> >    int stop = start + this.maximumIntegerDigits + maximumFractionDigits +
>> 2;
>> >    if (useExponentialNotation)
>> >      stop += minExponentDigits + 1;
>> >
>> > ->
>> >
>> >    int stop = start + maximumIntegerDigits;
>> >    if (maximumFractionDigits > 0)
>> >      stop += maximumFractionDigits + 1;
>> >     if (useExponentialNotation)
>> >      stop += (minExponentDigits > 0 ? minExponentDigits : 1) + 2;
>> >
>> >
>> > Note, however, that the test does not print the expected "12"
>> on Sun JRE 6.
>>
>> I'm not able to reproduce the desired behavior with Sun JRE:
>
> I repeat: Note, however, that the test does NOT print the expected "12" on 
> Sun JRE 6
>
> with Sun JRE: it prints 1234567890
> with Classpath: 1234
> with Classpath+this_patch: 12

Oh, right. Sorry abut that. I can indeed reproduce the behavior described above.

> I could simulate Sun JRE behavior but the author of the Classpath 
> DecimalFormat.parse() implementation (IMHO) wanted setMaximumIntegerDigits() 
> to act as expected. Any opinion what way should we follow?

I'm not a Classpath developer so my opinion doesn't matter that much.
I'm bit surprised, though, that we'd want behavior that doesn't match
Sun JRE. To me, any API behavior (even if it's a bug) that has lived
long enough in Sun JRE is what Classpath ought to aim at.
Compatibility is not just following the specification but also taking
real-world wrinkles into account.

                        Pekka

Reply via email to