-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8, 11, 14, 15
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
The documentation of java.util.Formatter (https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/util/Formatter.html#dpos) says regarding an explicit argument index:
> The first argument is referenced by "1$"
And regarding "Ordinary indexing":
> Ordinary indexing is used when the format specifier contains neither an argument index nor a '<'
However when using "0$" as explicit argument index, no exception is thrown but instead it is treated like "Ordinary indexing", i.e. the next sequential index is used.
Expected would be that either:
- An exception is thrown (preferred)
- The documentation is adjusted
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An exception to be thrown
ACTUAL -
Explicit index is treated like "Ordinary indexing"
---------- BEGIN SOURCE ----------
String.format("%0$s %0$s", "a", "b")
---------- END SOURCE ----------
The documentation of java.util.Formatter (https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/util/Formatter.html#dpos) says regarding an explicit argument index:
> The first argument is referenced by "1$"
And regarding "Ordinary indexing":
> Ordinary indexing is used when the format specifier contains neither an argument index nor a '<'
However when using "0$" as explicit argument index, no exception is thrown but instead it is treated like "Ordinary indexing", i.e. the next sequential index is used.
Expected would be that either:
- An exception is thrown (preferred)
- The documentation is adjusted
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
An exception to be thrown
ACTUAL -
Explicit index is treated like "Ordinary indexing"
---------- BEGIN SOURCE ----------
String.format("%0$s %0$s", "a", "b")
---------- END SOURCE ----------
- duplicates
-
JDK-8253459 Formatter treats index, width and precision > Integer.MAX_VALUE incorrectly
- Closed
- relates to
-
CODETOOLS-7902823 RepGen fails with IllegalFormatArgumentIndexException if started by JDK 16 and above
- Resolved
-
JDK-8253459 Formatter treats index, width and precision > Integer.MAX_VALUE incorrectly
- Closed