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

(fmt) Formatter.format(conv, args): IAE thrown when conv is b|B,h|H,s|S and args is empty array

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • tbd
    • 7u8
    • core-libs
    • None
    • x86
    • windows_xp

      As per the JDK7 spec wrt Formatter.format(), for the following conversion chars: b|B, h|H, s|S, IllegalArgumentException is not expected in for any argument value. For e.g., consider conversion char 'b', as per the spec:- 'If the argument is null, then the result is "false". If arg is a boolean or Boolean, then the result is the string returned by String.valueOf(). Otherwise, the result is "true".'

      Yet noticed that for String.format("%b", new Object[]{}), I get IAE. Instead I was expecting the "Otherwise" clause, that is a return value of: "true".

      Similar case noticed with other conversion chars such as: h|H, s|S.
      See attached testcase and the test output against JDK7 RI.

            Unassigned Unassigned
            satbhat Sathish Bhat
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: