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

(fmt) Formatter.format("%c", Integer.MAX_VALUE) generates recursive exception

XMLWordPrintable

    • b63
    • generic, x86
    • solaris_8, windows_xp

      FULL PRODUCT VERSION :
      java version "1.5.0_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      The format() method of java.util.Formatter is ending the application abruptly when an exception was expected.

      When I am trying to format a character (fromat specifier - c) with invalid values such as negative number (type casted to byte or short) the application is ending abruptly instead of throwing exceptions.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please execute the sample program.



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Since invalid values are passes, exceptions are expected to be thrown. Thus for the "sample program" submitted I expected exception stack trace.
      ACTUAL -
      Application ended abruptly with message

      Exception in thread "main"

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.*;
      public class BugTest
      {
      public static void main(String arg[])
      {
      Formatter frmt=new Formatter();
      try
      {
      frmt.format("char=\"%c\"\n",Integer.MAX_VALUE);
      }catch(Throwable ex)
      {
      ex.printStackTrace();
      }
      System.out.print(frmt.out());
      System.out.println("Completed");
      }
      }

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

            iris Iris Clark
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: