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

Sttring.format crashs with %.1g

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 7
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.7.0_05"
      Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
      Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux pcproels 3.1.10-1.9-desktop #1 SMP PREEMPT Thu Apr 5 18:48:38 UTC 2012 (4a97ec8) x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      String str = String.format("%.1g", 0.0);

      this crashs with

      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
      at java.lang.System.arraycopy(Native Method)
      at java.util.Formatter$FormatSpecifier.addZeros(Formatter.java:3401)
      at java.util.Formatter$FormatSpecifier.print(Formatter.java:3295)
      at java.util.Formatter$FormatSpecifier.print(Formatter.java:3190)
      at java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:2757)
      at java.util.Formatter$FormatSpecifier.print(Formatter.java:2708)
      at java.util.Formatter.format(Formatter.java:2488)
      at java.util.Formatter.format(Formatter.java:2423)
      at java.lang.String.format(String.java:2845)
      at psyvis.Main.main(Main.java:61)
      Java Result: 1



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      It should not throw an exception

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
              String str = String.format("%.1g", 0.0);
              System.err.println(str);

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

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: