Hi Pekka, Mon, 6 Dec 2010 10:54:09 +0200 (EET) Pekka Enberg <penb...@kernel.org>:
> [ Sorry for the delay. ] > > On Sat, 27 Nov 2010, Ivan Maidanski wrote: > > 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 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? Regards. > > $ ../Downloads/jdk1.6.0_22/bin/java -version > java version "1.6.0_22" > Java(TM) SE Runtime Environment (build 1.6.0_22-b04) > Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing) > $ ../Downloads/jdk1.6.0_22/bin/java DecimalFormatTest > 1234567890 > > Pekka