43 lines
1.2 KiB
Plaintext
43 lines
1.2 KiB
Plaintext
:source-highlighter: prettify
|
|
:source-language: java
|
|
:source-indent: 0
|
|
|
|
Because `printf`-style format strings are interpreted at runtime, rather than validated by the compiler, they can contain errors that result in the wrong strings being created. This rule statically validates the correlation of `printf`-style format strings to their arguments when calling the `format(...)` methods of `java.util.Formatter`, `java.lang.String`, `java.io.PrintStream`, `MessageFormat`, and `java.io.PrintWriter` classes and the `printf(...)` methods of `java.io.PrintStream` or `java.io.PrintWriter` classes.
|
|
|
|
== Noncompliant Code Example
|
|
----
|
|
include::noncompliant.java[lines=6..12]
|
|
----
|
|
----
|
|
include::noncompliant.java[lines=14..16]
|
|
----
|
|
----
|
|
include::noncompliant.java[lines=18..22]
|
|
----
|
|
----
|
|
include::noncompliant.java[lines=24..27]
|
|
----
|
|
----
|
|
include::noncompliant.java[lines=29..30]
|
|
----
|
|
|
|
== Compliant Solution
|
|
[source,indent=0]
|
|
----
|
|
include::compliant.java[lines=6..12]
|
|
----
|
|
----
|
|
include::compliant.java[lines=14..16]
|
|
----
|
|
----
|
|
include::compliant.java[lines=18..21]
|
|
----
|
|
----
|
|
include::compliant.java[lines=23..26]
|
|
----
|
|
----
|
|
include::compliant.java[lines=28..29]
|
|
----
|
|
|
|
== See
|
|
include::../see.adoc[] |