Files
openide/java/java-impl/resources/inspectionDescriptions/MalformedFormatString.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

23 lines
1.1 KiB
HTML

<html>
<body>
Reports format strings that don't comply with the standard Java syntax.
<p>By default, the inspection considers a compile-time constant a format string if it's used as an argument to the corresponding methods on
<code>java.util.Formatter</code>, <code>java.lang.String</code>, <code>java.io.PrintWriter</code> or <code>java.io.PrintStream</code>.
</p>
<p><b>Example:</b></p>
<pre><code>
String.format("x = %d, y = %d", 42);
</code></pre>
<!-- tooltip end -->
<p>Use the inspection settings to mark additional classes and methods as related to string formatting.</p>
<p>As an alternative, you can use the <code>org.intellij.lang.annotations.PrintFormat</code> annotation
to mark the format string method parameter. In this case,
the format arguments parameter must immediately follow the format string and be the last method parameter. Example:</p>
<pre><code>
void myFormatMethod(int mode, @PrintFormat String formatString, Object... args) {...}
</code></pre>
<p>
Methods annotated in this way will also be recognized by this inspection.
</p>
</body>
</html>