Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8131041

Garbage in output of DecimalFormat

XMLWordPrintable

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      $ java -version
      java version "1.8.0_45"
      Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

      $ javac Example.java

      $ LC_ALL=en_US.UTF-8 java Example
      [49, 48, 48, 32, 37]

      $ java -version
      java version "1.9.0-ea"
      Java(TM) SE Runtime Environment (build 1.9.0-ea-b72)
      Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b72, mixed mode)

      $ LC_ALL=en_US.UTF-8 java Example
      [49, 48, 48, -62, -96, 37]


      REGRESSION. Last worked in version 8u45


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.Arrays;
      import java.util.Locale;
      import java.text.DecimalFormat;
      import java.text.NumberFormat;

      public class Example {
        public static void main(String[] args) {
          NumberFormat f = DecimalFormat.getPercentInstance(Locale.FRENCH);
          System.out.println(Arrays.toString(f.format(1).getBytes()));
        }
      }

      ---------- END SOURCE ----------

            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: