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

Formatter treats index, width and precision > Integer.MAX_VALUE incorrectly

XMLWordPrintable

    • b26
    • Verified

      A DESCRIPTION OF THE PROBLEM :
      The source code of java.util.Formatter has 3 `assert(false)` statements:
      - When the argument index cannot be parsed as int
      - When the width cannot be parsed as int
      - When the precision cannot be parsed as int

      All of them can be triggered when the arguments are > Integer.MAX_VALUE. Expected would be that an exception is thrown.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected exceptions to be thrown

      ---------- BEGIN SOURCE ----------
      String.format("%2147483648s", 1) // Acts like no explicit width
      String.format("%s %2147483648$s", 1) // Acts like "Relative indexing"
      String.format("%.2147483648f", 1.0) // Acts like no explicit precision
      ---------- END SOURCE ----------

            igraves Ian Graves
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: